Embed a System.String in XAML

You should use Window.Resources

Here’s an example for Page, in your case it will be Window.Resources tag:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:System="clr-namespace:System;assembly=mscorlib">
  <Page.Resources>
    <System:String x:Key="MyString">Hello</System:String>
  </Page.Resources>
  <Grid>  
    <TextBlock Text="{StaticResource MyString}"></TextBlock>
  </Grid>
</Page>

Leave a Comment