物业在我的viewmodel中,我试图绑定到:WPF为什么这个绑定不起作用?
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>
最后的TextActionValue类:
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
}
text属性被填充。当我踏入它时,那里肯定有价值。
如果我只是绑定到一个基本的字符串属性它的作品。它不喜欢“TextActionValue.Text”。除非我做一些我想避免的重构,否则这不是一种选择。
如果我在TextActionValue中放置了一个断点get ... get不会被命中。所以这是告诉我绑定从来没有创建。为什么虽然...或者是我试图做不到的事情?
您的财产被称为'TextActionVal',但在您的TextBox的文本属性中,您正在设置绑定到'TextActionValue' – Dante
为什么世界上有人会投这个问题?谁在乎这是否是一个简单的疏忽。你说的是两个角色的差异。 – tronious
因为只有帮助一个人的问题毫无用处。 (学习[调试数据绑定](http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/30/debugging-data-bindings-in-a-wpf-or-silverlight-application.aspx )...) –