最需要注意的一点是,绑定一定要使用属性,因为属性提供{set;get;}方法。
XAML中的定义:
注意:需要在第二层ItemsControl的ItemsSource绑定的内容
<Window x:Class="Binding_Demo_01.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <ItemsControl x:Name="list1"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Center"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <<