如何在wpf中进行静态绑定 [英] how to do static binding in wpf

查看:91
本文介绍了如何在wpf中进行静态绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我遇到了问题。



i写一个xaml代码



Hi,

I am facing a problem.

i writing a xaml code

<Grid>
    <TabControl>
      <TabItem  Header="Details" Height="26" VerticalAlignment="Bottom">
        <Grid>
         <TextBox x:name = "txtname" text = {Binding name}/>
         <TextBox x:name = "txtage" text = {Binding age}/>
        </Grid>
      </TabItem>
      < <TabItem  Header="Summary" Height="26" VerticalAlignment="Bottom">
          <Grid>
           <label x:name = "lblname" content= {Binding Text, ElementName = txtname} />
           <label x:name = "lblage" Content = {Binding age, ElementName = txtage}/>
          </Grid>
      </TabItem>
    </TabControl>
</Grid>







您好我写了这段代码我在第一个面板上有2个文本框,在第2个面板上有标签。



无论我写入文本框,它都应显示在另一个标签的标签中。但它是写并行我想写只有当我将在两个文本框中写入并单击tab2点击选项卡我想显示标签内容。



请帮助我紧急。




Hi i wrote this code i have an 2 text boxes in 1st panel and label in 2nd panel.

whatever i am writing into text box it should display in label of another tab. but it is writing parallel i want to write only when i will write in both text box and click on tab2 on the click of tab i want to display label content.

please help me its urgent.

推荐答案

您可以将Label的updatesourcetrigger设置为explisit,并手动决定何时在第二个选项卡上显示更改。默认情况下,它设置为OnPropertyChange,这就是在您的属性更改后它发生变化的原因。
You can set updatesourcetrigger for your Label as explisit and manually decide when to Show changes on the second tab. By default it is set to OnPropertyChange, that's why it is changing after your property was changed.


<label x:name = "lblname" content= {Binding Text, ElementName = txtname, UpdateSourceTrigger=PropertyChanged} />


这篇关于如何在wpf中进行静态绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆