如何在XAML for WPF中使用Corporate if语句 [英] how I can in corporate if Statements in XAML for WPF
问题描述
如何在XAML中合并if语句?
我有一个主DataGrid.我绑定到数据库.但基于各种按钮,将打开数据库中的不同表.尽管每个表都链接到单个数据库,但每个表都有不同的列.因此,基于单击按钮,我只想执行某些XAML代码.其他代码将无效.它需要使用if语句.我该如何处理这种情况.我只想维护一个窗口来夸耀所有表.
也就是说,如果Mainwindow.xaml.cs中的语句是< b> sql ="Select * from Authors"</b>
执行此Segment< .. segment1 ..> Mainwidow.xaml中的残差
如果Mainwindow.xaml.cs中的语句为< b> sql ="Select * from ISBN"</b>
执行此Segment< .. segment2 ..> Mainwidow.xaml中的残缺物
任何类型的帮助都将得到感谢
在此先感谢
Iqbal
how I can incorporate if statements in XAML?
I have a Main DataGrid. which i binded to a Database. but based on various button click different tables from the Database will be opened. each table have dissimilar columns although it is linked to a single database.so based on the button click I want to execute only certain XAML codes . other codes will not be active. it requires the use of an if statement. how I can approach this situation. I want to maintain only one window to boast all tables .
ie if the statement in Mainwindow.xaml.cs is <b>sql="Select*from Authors"</b>
execute this Segment<..segment1..> of satement in Mainwidow.xaml
if the statement in Mainwindow.xaml.cs is <b>sql="Select*from ISBN"</b>
execute this Segment<..segment2..> of satement in Mainwidow.xaml
any type of help will be appreaciated
thanks in advance
Iqbal
推荐答案
一种方法可以是:
为每个单独的具有网格和其他功能的表创建一个user control
.然后将user control
动态加载到要在其中加载所有控件的窗口中.
例如,您可以在主窗口中添加StackPanel
,并根据您在if
声明之后做出的决定将新创建的用户控件添加到其Children
中.
在这里看看:
http://stackoverflow.com/questions/1774962/wpf-how-动态地执行i-load-user-controls [ ^ ]
希望对您有所帮助.
One approach can be this :
Make auser control
for every individual tables which have a grid and other facilities prepared in there. Then dynamically load thatuser control
into the window which you want to load all controls in there.
For example you can add aStackPanel
to your main window and add newly created user control to itsChildren
based on decision made after yourif
statements.
Have a look at here :
http://stackoverflow.com/questions/1774962/wpf-how-do-i-load-user-controls-dynamically[^]
Hope it helps.
这篇关于如何在XAML for WPF中使用Corporate if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!