【Silverlight 在运行时更改 ControlTemplate】教程文章相关的互联网学习教程文章

Silverlight 在运行时更改 ControlTemplate【代码】【图】

You cannot create a ControlTemplate in Silverlight in C# alone. Unlike WPF (where you can set the VisualTree property), there is no property you can set that specifies the "content" of the ControlTemplate.You can define your XAML as a string, and then load that dynamically in C# as explained by this blog post.The code boils down to:var template = (ControlTemplate)XamlReader.Load("<ControlTemplate ...

c# – Silverlight DataTemplate中的访问元素【代码】

即使在SO上已经存在一些相关问题,我也无法找到解决以下问题的干净解决方案. 如果我有一个多次使用的数据模板,例如TreeViewItem.HeaderTemplate,我怎样才能更改某些TreeViewItems的模板. 例如,假设我的TVI HeaderTemplate有一个文本块,根据字符串,我想使字体粗体. 我想做这样的事情:((TextBlock)myTreeView.Items.ElementAt(0).FindName("myTextBlock")).FontWeight = FontWeights.Bold;有人有解决方案吗? – &GT谢谢Evan 编辑:有...