【发布时间】:2012-05-25 10:07:25
【问题描述】:
我为我的 GameViewModel 创建了一个视图
我有一些类似的 xaml
<UserControl.Resources>
<DataTemplate DataType="{x:Type ViewModels:PlayerViewModel}">
<StackPanel>
<Button
Content="{Binding ?????}"
Command="{Binding WrongAnswerCommand}" />
<TextBlock
Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<ListBox Grid.Row="0"
ItemsSource="{Binding Players}"
IsSynchronizedWithCurrentItem="True">
</ListBox>
</Grid>
所以,这里是一个可观察的 Players 集合。
我需要将按钮内容绑定到 GameViewModel 的属性。
我应该使用什么?
【问题讨论】:
标签: wpf templates xaml binding