Xaml 在列表框WP8中绑定列表框
我需要在ContryListBox中绑定一个名为cityListBox的列表框,该列表框的类结构如下Xaml 在列表框WP8中绑定列表框,xaml,windows-phone-8,binding,listbox,Xaml,Windows Phone 8,Binding,Listbox,我需要在ContryListBox中绑定一个名为cityListBox的列表框,该列表框的类结构如下 public class Country { public Country(); public string ID { get; set; } public List<City> LstCity { get; set; } public string Title { get; set; } } 公共类国家 { 公共国家(); 公共字符串ID{g
public class Country
{
public Country();
public string ID { get; set; }
public List<City> LstCity { get; set; }
public string Title { get; set; }
}
公共类国家
{
公共国家();
公共字符串ID{get;set;}
公共列表{get;set;}
公共字符串标题{get;set;}
}
我希望我的外部列表框应该带有国家名称作为标题,在Inner列表框的城市标题中,城市也是一个带有Id和标题的类
我的xaml代码:
<ListBox x:Name="ContryListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Bewise:ExpanderControl HeaderText="{Binding Title, Mode=OneWay}" >
<Bewise:ExpanderControl.ContentArea>
<ListBox x:Name="cityListBox " >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox></CheckBox>
<TextBlock Text="{Binding Title}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Bewise:ExpanderControl.ContentArea>
</Bewise:ExpanderControl>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--Added ItemsSource binding-->
<ListBox x:Name="ContryListBox" ItemsSource="{Binding YourCountryListProperty}>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Bewise:ExpanderControl HeaderText="{Binding Title, Mode=OneWay}" >
<Bewise:ExpanderControl.ContentArea>
<!--Added ItemsSource Binding-->
<ListBox x:Name="cityListBox" ItemsSource="{Binding LstCity}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox></CheckBox>
<TextBlock Text="{Binding Title}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Bewise:ExpanderControl.ContentArea>
</Bewise:ExpanderControl>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>