我们直接通过xaml文件演示一个简单的xaml集合项:
<Window x:Class="WPF_XAML集合项.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="" Width=""> <Grid>
<ComboBox Height="" HorizontalAlignment="Left" Margin="50,30,0,0" Name="comboBox1" VerticalAlignment="Top" Width="" >
<ComboBox.Items>
<!--集合项-->
<ComboBoxItem>中国</ComboBoxItem>
<ComboBoxItem>美国</ComboBoxItem>
<ComboBoxItem>日本</ComboBoxItem>
<!--文本-->
<TextBlock>A</TextBlock>
<TextBlock>B</TextBlock>
<TextBlock>C</TextBlock>
<TextBlock Height="" Text="你好" FontFamily="Agency FB" FontSize="">
<TextBlock.Foreground>
<ImageBrush ImageSource="123.jpg" />
</TextBlock.Foreground>
</TextBlock>
<!--图片-->
<Image Source="123.jpg" Height="" Width=""></Image>
<!--自定义图形-->
<Rectangle Width="" Height="" Fill="Blue"></Rectangle> </ComboBox.Items>
</ComboBox> </Grid>
</Window>
效果展示:
示例下载:
http://files.cnblogs.com/BABLOVE/WPFXAML%E9%9B%86%E5%90%88%E9%A1%B9.rar