我想将一个数据绑定到多个控件。WPF中是否有一些逻辑控制来实现这一点?例如我有一个Grid
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" />
<Button Grid.Column="1" Grid.RowSpan="2" IsEnabled="{Binding IsSimulationRunning}" />
<controls:PlayerControl Grid.Row="1" IsEnabled="{Binding IsLoaded}" />
</Grid>
我想绑定TextBlock
到一个数据和Button
另一个数据PlayerControl
,如下所示:
<Container DataContext="{Binding Object2}">
<Button IsEnabled="{Binding IsSimulationRunning}" />
<controls:PlayerControl IsEnabled="{Binding IsLoaded}" />
</Container>
我怎样才能以最好的方式做到这一点?