我有一个ListBox
:
<ListBox Name="ListB" SelectedIndex="0" ItemsSource="{Binding Account}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock FontSize="16" Grid.Column="0" Grid.RowSpan="3">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}" >
<Binding Path="AccountNumber" />
<Binding Path="Name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
基于AccountNumber
我想要Show/Hide
DataGrid's
绑定到 ListBoxItems:
<!--DataGrid 1-->
<DataGrid ItemsSource="{Binding ElementName=ListB, Path=SelectedItem}">
..................
</DataGrid>
<!--DataGrid 2-->
<DataGrid ItemsSource="{Binding ElementName=ListB, Path=SelectedItem}">
..................
</DataGrid>
WPF中有if/else吗?例如
if SelectedItem in ListBox has an AccountNumber 100
than show DataGrid 1 and hide DataGrid 2
else hide DataGrid 1 and show DataGrid 2.
预先感谢您的提示。