c# - Set style of TextBlock programatically -


i have this:

var mytext = new textblock(); mytext.text = "blah"; mytext.style = /* ??? */; 

in xaml, can set style this:

<textblock text="blah" style="{themeresource listviewitemtextblockstyle}"/> 

but how do in c#?

edit:

error   1   'windows.ui.xaml.application' not contain definition 'findresource' , no extension method 'findresource' accepting first argument of type 'windows.ui.xaml.application' found (are missing using directive or assembly reference?) error   1   'geodropper.hubpage' not contain definition 'findresource' , no extension method 'findresource' accepting first argument of type 'geodropper.hubpage' found (are missing using directive or assembly reference?) 

when tried (style)this.findresource("listviewitemtextblockstyle"); , (style)app.current.findresource("listviewitemtextblockstyle") got these errors.

thank decoherence! needed following:

var mytext = new textblock(); mytext.text = drop; mytext.style = (style)application.current.resources["listviewitemtextblockstyle"]; 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -