I have this:
var MyText = new TextBlock();
MyText.Text = "blah";
MyText.Style = /* ??? */;
In XAML, I can set a style like this:
<TextBlock Text="blah" Style="{ThemeResource ListViewItemTextBlockStyle}"/>
But how do I do that in C#?
EDIT:
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 found (are you missing a using directive or an assembly reference?)
When I tried (Style)this.FindResource("ListViewItemTextBlockStyle");
and (Style)App.Current.FindResource("ListViewItemTextBlockStyle")
I got these errors.
Thank you decoherence! What I needed was the following:
var MyText = new TextBlock();
MyText.Text = drop;
MyText.Style = (Style)Application.Current.Resources["ListViewItemTextBlockStyle"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With