I have a user control with the following elements
<Grid>
<StackPanel Orientation="Horizontal" Width="150" Height="150">
<TextBlock Text="hai"> </TextBlock>
<TextBox Text="{Binding DeviceName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<TextBlock Text="{Binding DeviceID, Mode=TwoWay}"></TextBlock>
<TextBlock Text="{Binding Test, Mode=TwoWay}"></TextBlock>
</StackPanel>
</Grid>
I am setting the DataContext like below
public partial class WorkFlowManager : UserControl
{
public WorkFlowManager()
{
InitializeComponent();
this.DataContext = new WorkFlowManagerVM();
}
}
And my WorkflowManagerVM implements INotifyPropertyChanged
public class WorkFlowManagerVM : INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
public void RisePropertyChanged(string PropertyName)
{
if(PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
}
The Propertchanged event is always null. Is there any problem the way I set the DataContext. This User control will be inside MainWindow. Not sure what has gone wrong.