在运行时激活XAML代码 [英] Activating XAML code during runtime

查看:83
本文介绍了在运行时激活XAML代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以将XAML代码段合并到C#代码隐藏中,以便它可以在运行时执行并根据某些事件具有相同的效果

即像这样的东西

is there any method to incorporate XAML code segment into C# codebehind so that it will be executed at run time and will have the same effect based on certain events

ie something like this

private void button1_Click(object sender, RoutedEventArgs e)
       {
 some type of handling here

<TextBlock Text="{Binding ElementName=SampleText,
Path=Text}"
FontFamily="{Binding ElementName=FontList,
Path=SelectedItem}"
FontSize="32"
TextWrapping="Wrap" />

       }




在此先感谢




thanks in advance

推荐答案

看看XamlReader.Load:

http://msdn.microsoft.com/en-us/library/system. windows.markup.xamlreader.aspx [ ^ ]
Take a look at XamlReader.Load:

http://msdn.microsoft.com/en-us/library/system.windows.markup.xamlreader.aspx[^]


这篇关于在运行时激活XAML代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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