使用XAML代碼取得.Net預定義顏色:
<Page
XMLns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
XMLns:x="
http://schemas.microsoft.com/winfx/2006/xaml"
XMLns:r="clr-namespace:System.Reflection;assembly=mscorlib"
>
<Page.Resources>
<ObjectDataProvider x:Key="
ColorsProps"
ObjectInstance="{x:Type Colors}" MethodName="GetPropertIEs">
<ObjectDataProvider.MethodParameters>
<r:BindingFlags>Public, Static</r:BindingFlags> </ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<DataTemplate x:Key="
colorTemplate"
DataType="{x:Type r:PropertyInfo}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle Fill="{Binding Name}" Grid.Column="0"
Width="100" Height="24" Margin="2"
HorizontalAlignment="Center"/>
<TextBlock Margin="6,3,3,
3" Text="{Binding Name}"
Grid.Column="1" HorizontalAlignment="Center"
FontSize="16"/>
</Grid>
</DataTemplate>
</Page.Resources>
<StackPanel>
<ComboBox ItemsSource="{Binding Source={StaticResource ColorsProps}}"
ItemTemplate="{StaticResource colorTemplate}"
SelectedValuePath="Color"/>
</StackPanel>
</Page>
http://shevASPace