Silverlight-listbox.ItemTemplate的动态绑定
我有这个:Silverlight-listbox.ItemTemplate的动态绑定,silverlight,binding,Silverlight,Binding,我有这个: <ListBox x:Name="PART_lstAttributes" Grid.Row="1" Style="{StaticResource GlossyBlackListBox}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock x:Name="txtAttributeName" Text="{Bind
<ListBox x:Name="PART_lstAttributes" Grid.Row="1" Style="{StaticResource GlossyBlackListBox}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock x:Name="txtAttributeName" Text="{Binding AttributeName}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
请注意,这个绑定到我的集合的“AttributeName”属性。我希望能够以编程方式将“AttributeName”更改为其他内容。这可能吗 假设您的数据项是启用了字符串或ToString的,则以下解决方案将使用显式绑定的属性
<DataTemplate>
<StackPanel>
<TextBlock x:Name="txtAttributeName" Text="{Binding}"></TextBlock>
</StackPanel>
</DataTemplate>
简短但对我很有帮助。谢谢