KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Quick question... I have a ListBox with its ItemsSource property bound to a collection property in a viewmodel like so: <ListBox Name="CollectionsListBox" ItemsSource="{Binding Activity.Timesheets}" /> I also have two Button objects in the same view. The question is... can I change the CollectionsListBox ItemsSource Binding from Activity.Timesheets to Activity.Attachments using just XAML? Failing that, from the viewmodel using Command objects? EDIT >>> I found a simple solution by using RadioButton s instead of Button s from part of Howard's answer: <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> Many thanks for the help.
Tags (comma-separated)
Save Edits
Cancel