I'm trying to make a UserControl which has it's own Viewmodel.
I used dp to pass parameter from View to my UserControl.
public object SelectedItemCliEnt
{
get { return (object)GetValue(SelectedItemEntProperty); }
set { SetValue(SelectedItemEntProperty, value); }
}
public static readonly DependencyProperty SelectedItemEntProperty =
DependencyProperty.Register("SelectedItemCliEnt", typeof(object),
typeof(UCComboBoxClient), new PropertyMetadata(null));
Now, in my user control I bound the datagrid SelectedItem to this property:
<DataGrid x:Name="dtg_entite"
ItemsSource="{Binding CliColl, Source={StaticResource vm}}">
<DataGrid.SelectedItem>
<MultiBinding Converter="{StaticResource MultiBinding}"
Mode="TwoWay">
<Binding Path="SelectedCli"
Source="{StaticResource vm}"
Mode="TwoWay" />
<Binding Path="SelectedItemCliEnt"
Mode="TwoWay"
RelativeSource="{RelativeSource AncestorType={x:Type UC:UCComboBoxClient}, Mode=FindAncestor}" />
</MultiBinding>
</DataGrid.SelectedItem>
</DataGrid>
I also bound the selectedItem to a property (SelectedCli) in my ViewModel which I can access by using a resources, it allow me to modify the content of the datagrid:
<ViewModel:VMUCCBClient x:Key="vm" />
How can I notify to SelectedItemCliEnt the changes in SelectedCli from the UserControl's ViewModel?