Dependency property binding Issue WPF
Kindly Let me Know where I am wrong
Xaml --- Xaml of User Control where I use my child user control with
dependency property
ComboBox SelectedItem will Update SelectedEmployee, This SelectedEmployee
is further Binded with My child Control CardView:uEmployeeCard ViewModel
Property---
<ComboBox Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
Style="{StaticResource UiComboBox}" ItemsSource="{Binding
TB_EMPLOYEEList}" SelectedItem="{Binding SelectedEmployee, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="ID" SelectedValue="{Binding
CurrentTB_RECIEPT.REFRENCEID}"
ItemTemplate="{StaticResource
ComboEmployeeTemplate}"/>
<CardView:uEmployeeCard ViewModel="{Binding
Path=SelectedEmployee}" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="2" Grid.RowSpan="3"
VerticalAlignment="Top"/>
------------Dependency Property Code , Code Behind file of uEmployeeCard ----
public uEmployeeCard()
{
InitializeComponent();
this.DataContext = this;
}
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel",
typeof(TB_EMPLOYEE), typeof(uEmployeeCard), new
FrameworkPropertyMetadata
{
BindsTwoWayByDefault = true,
DefaultUpdateSourceTrigger =
UpdateSourceTrigger.PropertyChanged
});
[Bindable(true)]
public TB_EMPLOYEE ViewModel
{
get { return (TB_EMPLOYEE)GetValue(ViewModelProperty); } //do
NOT modify anything in here
set { SetValue(ViewModelProperty, value); } //...or here
}
-------Xaml File of uEmployeeCard (Child User Control)-----
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.TITLE}"/>
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.FIRSTNAME}"/>
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.FIRSTNAME}"/>
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="1"
Orientation="Vertical" Grid.RowSpan="2">
<TextBlock Style="{StaticResource UiTextBlock}"
Text="{Binding Path=ViewModel.NATNO}"/>
</StackPanel>
I put breakpoint to check whether the Dependency property get affected..on
update from Combo on parent user control. but not...
Kindly let me know where I am wrong, Thanks a lot.
No comments:
Post a Comment