Windows Phone应用程序-XAML if语句 [英] Windows Phone App - XAML if statements

查看:113
本文介绍了Windows Phone应用程序-XAML if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的"page1.XAML" ,如果我的"page1.xaml.cs"中的布尔变量没错.

I want to create button in my " page1.XAML" , if a boolean variable in my "page1.xaml.cs" calss is true.

如何在XAML部分而不是c-sharp部分中编写代码?

How do i write the code in the XAML part and not c-sharp part?

我知道我可以使用类的c-sharp部分轻松地创建此按钮,但是我希望按钮位于特定位置,而不仅仅是创建新按钮时的默认位置.

I understand i can create this easily using the c-sharp part of the class, but i want the button to be in a specific place, not just the default place when new buttons are created.

推荐答案

如何在XAML中创建按钮,但是将其可见性设置为布尔值与可见性转换器的值?

How about you create a button in XAML but set its visibility bind with value of a Boolean to Visibility converter?

您也可以通过更改按钮的相对边距或与后面的代码绑定的变量关联的Grid.Row或Grid.Column,对位置执行相同的操作.

You can also do the same with position by changing button's relative margin or associated Grid.Row or Grid.Column bound with variables from code behind.

在这里您可以看到可见性转换器的使用情况,

Here's where you can see the use of visibility converter,

http://compiledexperience.com/blog/posts/useful-calue-converters

http://compiledexperience.com/blog/posts/useful-calue-converters


这篇关于Windows Phone应用程序-XAML if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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