小编Zud*_*udo的帖子

以编程方式设置TextBlock的样式

我有这个:

var MyText = new TextBlock();
MyText.Text = "blah";
MyText.Style = /* ??? */;
Run Code Online (Sandbox Code Playgroud)

在XAML中,我可以设置这样的样式:

<TextBlock Text="blah" Style="{ThemeResource ListViewItemTextBlockStyle}"/>
Run Code Online (Sandbox Code Playgroud)

但是我如何在C#中做到这一点?

编辑:

Error   1   'Windows.UI.Xaml.Application' does not contain a definition for 'FindResource' and no extension method 'FindResource' accepting a first argument of type 'Windows.UI.Xaml.Application' could be found (are you missing a using directive or an assembly reference?)
Error   1   'Geodropper.HubPage' does not contain a definition for 'FindResource' and no extension method 'FindResource' accepting a first argument of type 'Geodropper.HubPage' could be …
Run Code Online (Sandbox Code Playgroud)

c# xaml visual-studio windows-phone-8.1

8
推荐指数
1
解决办法
4251
查看次数

标签 统计

c# ×1

visual-studio ×1

windows-phone-8.1 ×1

xaml ×1