I have created one Tab application which contains One main window and related tab, each tab has a separate View-Model.
Each tab initialized one by one, Once the app is open properly then I want to update some values form the second tab and these changes should be reflected on the First tab.
So I have implemented INotifyPropertChanged event related to these properties but it's not reflected on First Tab.
It seems there is some problem in DataContext is not updated properly while changing the value in the second tab.
What I have tried:
I have tried to updated First tab DataContext while changing the values(Property's setter) form the Second tab. I have seen in debugging the property has updated but it's not reflected in GUI.
Thanks.
<pre>
public partial class PersonUserControl : UserControl
{
public PersonUserControl ()
{
InitializeComponent();
if ( !DesignerProperties.GetIsInDesignMode(this) )
{
DataContext = new PersonViewModel();
}
}
public string JoinDate
{
get
{
return _joinDate;
}
set
{
if (_joinDate != value)
{
_joinDate = value;
OnPropertyChanged("JoinDate");
}
}
}
<pre> <TextBlock FontWeight="Bold"
Height="28"
HorizontalAlignment="Left"
Margin="30,350,0,0"
Text="{Binding JoinDate, Mode=OneWay}"
VerticalAlignment="Top" />
public partial class UpdateInfoControl : UserControl
{
public UpdateInfoControl()
{
InitializeComponent();
if ( !DesignerProperties.GetIsInDesignMode(this) )
{
DataContext = new UpdateInfoModel();
}
}
public DateTime TimeOfDay
{
get
{
return _timeOfDay;
}
set
{
if ( _timeOfDay != value )
{
_timeOfDay = value;
OnPropertyChanged("TimeOfDay");
_updateInfoViewModel.JoinDate = timeOfDay .ToString();
}
}
}
<DatePicker Height="26"
HorizontalAlignment="Right"
Margin="0,69,239,0"
SelectedDate="{Binding TimeOfDay, Mode=TwoWay}"
SelectedDateFormat="Long"
VerticalAlignment="Top"
Width="208" />