4
这个工程。WPF - 风格二传手属性绑定
<Setter Property="Width" Value="300" />
<Setter Property="Height" Value="300" />
但是,当我改变这一点,不起作用。
<Setter Property="Width" Value="{Binding ImageSize, Mode=TwoWay}" />
<Setter Property="Height" Value="{Binding ImageSize, Mode=TwoWay}" />
,并宣布
private Int32 imageSize;
public Int32 ImageSize
{
get { return imageSize; }
set
{
imageSize = value;
NotifyPropertyChanged("ImageSize");
}
}
有什么不对?
你在哪里设置样式适用的项目'DataContext'? –
在UserControl上, DataContext =“{Binding ElementName = CodeBehind}” – mozkarakoc
然后您是否有名为CodeBehind的UserControl?最可能的原因是它无法在'DataContext'上找到ImageSize属性。检查您的输出窗口以查看是否存在任何绑定错误,并且可能会发布更多代码,因此更容易排除故障。 –