I got a custom WPF property class named "RFPGegevens"
public class RFPGegevens
{
private string _klant;
public String Klant
{
get { return _klant; }
set { _klant = value; }
}
}
In my ViewModel I got a property RFPGegevens
private RFPGegevens _rfpGegevens;
public RFPGegevens RfpGegevens
{
get
{
if (_rfpGegevens == null)
_rfpGegevens = new RFPGegevens();
return _rfpGegevens;
}
set
{
_rfpGegevens = value;
base.RaisePropertyChangedEvent("RfpGegevens");
}
}
This property is filled correctly, if I debug this is the result:
In my View I'm binding the property "RFPGegevens" to the datacontext of my Grid
<Grid DataContext="{Binding RfpGegevens}">
and still if I debug the "Klant" property field is filled.
But as I bind this property in the View my textbox is still empty.
<TextBox Text="{Binding Klant, Mode=TwoWay}"/>
I also tried this but nothings seems to work:
<TextBox Text="{Binding RFPGegevens.Klant, Mode=TwoWay}"/>
Don't know what I'm doing wrong.
Thanks in advance ;)
try with two things
<TextBox Text="{Binding Klant, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
public class RFPGegevens
{
private string _klant;
public String Klant
{
get { return _klant; }
set {
_klant = value;
//Raise the property changed event here
}
}
}
You need to implement the INotifyPropertyChanged interface for your custom class also as below:
public class RFPGegevens : INotifyPropertyChanged
and raise the propertychanged events from the set accessor of your properties.
您忘记从INotifyPropertyChanged添加继承
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.