Property in my viewmodel that I’m trying to bind to:
private TextActionValue _textActionVal;
public TextActionValue TextActionVal
{
get { return _textActionVal; }
set
{
_textActionVal = value;
}
}
xaml:
<Grid Margin="0,15,15,15" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="1" BorderThickness="0">
<TextBox Margin="0,5,0,5" AcceptsReturn="True" AcceptsTab="True" Text="{Binding TextActionValue.Text}" HorizontalAlignment="Stretch" MinHeight="100"></TextBox>
</GroupBox>
</Grid>
And finally the TextActionValue class:
public class TextActionValue : ISomeAction, INotifyPropertyChanged
{
private String _text;
public String Text
{
get { return _text; }
set
{
_text = value;
OnPropertyChanged("Text");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
The text property is filled. There’s definitely a value in there when I step it.
If I just bind to a basic string property it works. It does not like “TextActionValue.Text”. This is not an option unless I do some refactoring which I want to avoid if I can.
If I put a breakpoint inside of TextActionValue get…the get is never hit. So this is telling me the binding is never created. Why though…or is what I’m trying to do not possible?
Try binding to
TextActionVal.Textinstead ofTextActionValue.TextYou are trying to bind to the class not the property.
Also check your output window while debugging to see data binding errors.