[英]wpf dynamic border thickness binding
我有一個動態生成的邊框。 我想將其厚度屬性與樣式模型綁定在一起。
Border db = new Border();
Binding borderthickness = new Binding();
borderthickness.Source = this.imodel.GridStyleProperties.BorderThickness;
borderthickness.Path = new PropertyPath("BorderThickness");
BindingOperations.SetBinding(db, Border.BorderThicknessProperty, borderthickness);
到目前為止,這是我所做的。 它對我不起作用。
請建議我這段代碼有什么問題。
謝謝
您將綁定到BorderThickness
對象,並且Path
設置為BorderThickness
。 這意味着綁定將在不存在的this.imodel.GridStyleProperties.BorderThickness.BorderThickness
中查找。
嘗試
borderthickness.Source = this.imodel.GridStyleProperties;
borderthickness.Path = new PropertyPath("BorderThickness");
要不就
borderthickness.Source = this.imodel.GridStyleProperties.BorderThickness;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.