从WPF中的FrameworkElementFactory获取UIElement [英] get the UIElement from FrameworkElementFactory in WPF
本文介绍了从WPF中的FrameworkElementFactory获取UIElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从FrameorkelemntFactory获取UI元素,因为我的代码是
How can i get the UI element from FrameorkelemntFactory as my code is
FrameworkElementFactory objFrame = new FrameworkElementFactory(typeof(TextBlock));
objFrame.SetValue(TextBlock.TextProperty, "country");
objFrame.Name="somename";
DataTemplate dt1 = new DataTemplate();
dt1.VisualTree = objFrame;
如果我想访问TextBlock的text属性我该怎么做?
i尝试了类似
$ b的东西$ b
if i want to access the text property of the TextBlock how can i do this?
i have tried something like
TextBlock txt = dt1.FindName("somename", (FrameworkElement)TextBlock) as TextBlock;
但显示错误...
有人可以帮我吗
提前感谢........
but its showing errors...
can anybody help me
thanks in advance........
推荐答案
你可以试试遵循Code。
dt1.LoadContent()as TextBlock;
You Can Try Follow Code.
dt1.LoadContent() as TextBlock;
这篇关于从WPF中的FrameworkElementFactory获取UIElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文