本文介绍了绑定反向值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在布局中有两个按钮添加名称和退出以及一个文本框。我想当程序运行时添加名称变为禁用并且退出变为启用。当用户在文本框中输入名称时,添加名称变为启用,退出变为禁用。

如何从路径获取反向值,当程序运行时退出按钮变为启用。



我的尝试:



< Grid> 
< TextBox Name =txtNameWidth =100Height =30Margin =206,82,211,207>< / TextBox>
< Button Content =Add NameWidth =100Height =30IsEnabled ={Binding ElementName = txtName,Path = Text.Length,Mode = OneWay}Margin =102,144,315,145> < /按钮>
< Button Content =ExitWidth =100Height =30IsEnabled ={Binding ElementName = txtName,Path = Text.Length,Mode = OneWay}Margin =312,144,105,145>< ; /按钮>
< / Grid>
解决方案

I have two Buttons "Add Name" and "Exit" and One TextBox in layout.I want When program runs "Add Name" become disable and "Exit" become enable. When user enter name in Textbox "Add Name" become enable and "Exit" become disable.
How to get inverse value from Path that "Exit" button become enable when program run.

What I have tried:

<Grid>
    <TextBox Name="txtName" Width="100" Height="30" Margin="206,82,211,207"></TextBox>
    <Button Content="Add Name " Width="100" Height="30" IsEnabled="{Binding ElementName=txtName, Path=Text.Length, Mode=OneWay}" Margin="102,144,315,145"></Button>
    <Button Content="Exit " Width="100" Height="30" IsEnabled="{Binding ElementName=txtName, Path=Text.Length, Mode=OneWay}" Margin="312,144,105,145"></Button>
</Grid>
解决方案


这篇关于绑定反向值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 10:00