簡単な質問...
次のように、ビューモデルのコレクション プロパティにプロパティがバインドされていますListBox
。ItemsSource
<ListBox Name="CollectionsListBox" ItemsSource="{Binding Activity.Timesheets}" />
また、同じビューに 2 つのButton
オブジェクトがあります。問題は... XAML のみを使用CollectionsListBox
ItemsSource Binding
するActivity.Timesheets
ように変更できますか?Activity.Attachments
コマンドオブジェクトを使用してビューモデルから失敗しましたか?
編集 >>>
ハワードの回答の一部からRadioButton
s の代わりにsを使用して、簡単な解決策を見つけました。Button
<ListBox Name="CollectionsListBox">
<ListBox.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=TimesheetsButton,Path=IsChecked}" Value="True">
<Setter Property="ListBox.ItemsSource" Value="{Binding Activity.Timesheets}" />
<Setter Property="ListBox.ItemContainerStyle" Value="{StaticResource TimesheetStyle}" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=AttachmentsButton,Path=IsChecked}" Value="True">
<Setter Property="ListBox.ItemsSource" Value="{Binding Activity.Attachments}" />
<Setter Property="ListBox.ItemContainerStyle" Value="{StaticResource AttachmentStyle}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.Style>
</ListBox>
助けてくれてありがとう。