Views/BrushesView.xaml.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MahAppsMetro.Demo.Views
{
/// <summary>
/// BrushesView.xaml 的互動邏輯
/// </summary>
public partial class BrushesView : UserControl
{
public BrushesView()
{
InitializeComponent();
Loaded += BrushesView_Loaded;
}
private void BrushesView_Loaded(object sender, RoutedEventArgs e)
{
ShowBrushes();
}
public void ShowBrushes()
{
//使用映射
foreach (System.Reflection.PropertyInfo item in typeof(Brushes).GetProperties())
{
Rectangle rect = new Rectangle() { Width = 200, Height = 50, Fill = (SolidColorBrush)item.GetValue(null, null) };
TextBlock text = new TextBlock() { Text = item.Name, HorizontalAlignment = System.Windows.HorizontalAlignment.Center };
StackPanel sp = new StackPanel() { Margin = new Thickness(5) };
sp.Children.Add(rect);
sp.Children.Add(text);
//App.Control
this.wrappanel.Children.Add(sp);
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。