Hi my Problem is I haven't any Idea how I send Data from my UserControls to other UserControls or Windows in my Project.
My Project is a .Net 7 WPF-Project.
I have one FilterControl where Checkboxes and/or Textboxes filtering a List. The List exists in this FilterControl.
And after this filtering I want to send die filtered List to an other UserControl to show the List.
Aside from that I want to send the List to an Window.
How can I do that?
This is the MainWindow
<Window x:Class="MyProject.MainWindow"
xmlns:FilterCtrl="clr-namespace:MyProject.FilterControl"
xmlns:ListCtrl="clr-namespace:MyProject.ListControl">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<FilterCtrl:FilterControl/>
<ListCtrl:ListControl/>
</Grid>
</Window>
The UserControls:
SubFilter
<UserControl x:Class="MyProject.SubFilter">
<UserControl.DataContext>
<local:SubFilterViewModel/>
</UserControl.DataContext>
<Grid>
<CheckBox Command="{Binding CheckBoxCommand1}" Content="FilterOption1" Checked="{Binding CheckBool1}">
<CheckBox Command="{Binding CheckBoxCommand2}" Content="FilterOption2" Checked="{Binding CheckBool2}">
</Grid>
</UserControl>
FilterControl
<UserControl x:Class="MyProject.FilterControl
xmlns:SubFilterCtrl="clr-namespace:MyProject.SubFilterControl">
<UserControl.DataContext>
<local:FilterViewModel/>
</UserControl.DataContext>
<Grid>
<SubFilterCtrl:SubFilterControl/>
<TextBox Command="{Binding TextBoxCommand}" Text="AnotherFilterOption">
</Grid>
</UserControl>
ListControl
<UserControl x:Class="MyProject.ListControl
xmlns:ListCtrl="clr-namespace:MyProject.ListControl">
<UserControl.DataContext>
<local:FilterViewModel/>
</UserControl.DataContext>
<Grid>
<ListView MaxHeight="500" ItemsSource="{Binding FilteredList}" SelectedItem="{Binding SelectedColumm}">
<ListView.View>
<GridView AllowsColumnReorder="true">
<GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Name" Width="200"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>
I Use an Relay Command from this Side: RelayCommand
The List for Filtering are simple Objects with some Properties. Here only Name.
With the SubFilter I want only filtering with Checkboxes, and want back a List with the booleans from the CheckBoxes The FilterControl filtering with these List from SubFilter and his own FilterOptions. The ListControl should only show the List.