开发者

how to bind to control inside expanders' contentemplate

I have a textbox inside a Expasnders contentemplate that I'm trying to bind to from outside the expander, but it's not really possible, I have another textbox inside the expander looking like this:

and an exact duplicate of this markup outside t开发者_运维技巧he expander, The textbox inside the expander updates it's text proeprty when txtTitle is changed, the one outside doesn't so how do I get bind to txtTitle from outside the expander??

I will try to illustrate it with some sample xaml (sounds fun pronounced).

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

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

The problem is that the binding wont work because ExpandertxtBox is inside a contentemplate, and I'm trying to bind from outside, so how can I access it, what is the correct bindingpath?


I Ended up creating this method to handle my problem

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜