开发者

How do you bind to dynamic content in wpf?

开发者 https://www.devze.com 2023-01-24 13:57 出处:网络
My Situation put simply is that if i have a textbox, lets call it A. when i update the value in this text box it should update a label - B.

My Situation put simply is that if i have a textbox, lets call it A. when i update the value in this text box it should update a label - B. when B changes then it should update another label C.

so, effectively i wish to emply binding in the form of C bind to B which binds to A.

i have tried the following but C never gets updated.

    <TextBox Grid.Row="0" Name="A"/>        
    <Label Grid.Row="开发者_运维百科1" Name="B" Content="{Binding Text, ElementName=A, UpdateSourceTrigger=PropertyChanged}"/>
    <Label Grid.Row="2" Name="C" Content="{Binding Text, ElementName=B}"/>


Try it like this:

<TextBox Grid.Row="0" Name="A"/>
<Label Grid.Row="1" Name="B" Content="{Binding Text, ElementName=A}"/>
<Label Grid.Row="2" Name="C" Content="{Binding Content, ElementName=B}"/>

You have to bind to the Content property.

0

精彩评论

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