我有我的课:
public class CustomCell
{
public string BindingData
{
get { return (string)GetValue(BindingDataProperty); }
set { SetValue(BindingDataProperty, value); }
}
public static readonly DependencyProperty BindingDataProperty =
DependencyProperty.Register("BindingData", typeof(string), typeof(CustomCell));
}
我使用 BindingDataProperty 设置绑定
CustomCell cell = new CustomCell();
cell.SetBinding(CustomCell.BindingDataProperty, new Binding("source"));
现在我想使用以下命令获取 XAML 等效字符串XamlWriter
:
string xaml = XamlWriter.Save(cell);
但是在xaml
字符串BindingData
中是{x:Null}
并且没有进行任何绑定。
为什么?我怎么解决这个问题?