0

我在 Expasnders 内容模板中有一个文本框,我试图从扩展器外部绑定它,但这实际上是不可能的,我在扩展器中有另一个文本框,如下所示:

以及扩展器外部此标记的精确副本,当 txtTitle 更改时,扩展器内的文本框会更新其文本属性,外部的文本框没有,所以我如何从扩展器外部绑定到 txtTitle?

我将尝试用一些示例 xaml 来说明它(听起来很有趣)。

<TextBox Text="{Binding ElementName=ExpandertxtBox, Path=Text}" />

<toolkit:Expander>
<toolkit:Expander.ContentTemplate>
<TextBox Name="ExpandertxtBox" />
</toolkit:Expander.ContentTemplate>
</toolkit:Expander>

问题是绑定不起作用,因为 ExpandertxtBox 在内容模板内,而我试图从外部绑定,那么我该如何访问它,正确的绑定路径是什么?

4

1 回答 1

0

我最终创建了这个方法来处理我的问题

private void SetFilterBinding(object ctrl, object value, FilterOperator fo, string ctrlproperty, string dbproperty)
{
    var fd = new FilterDescriptor(dbproperty, fo, value);
    BindingOperations.SetBinding(fd, FilterDescriptor.ValueProperty, new Binding{ Path = new PropertyPath(ctrlproperty), Source = ctrl});
    nodeDomainDataSource.FilterDescriptors.Add(fd);
}
于 2010-08-20T22:52:51.287 回答