WPF Resources – Hello Resources

WPF introduces a very handy concept: The ability to store data as a resource, either locally for a control, locally for the entire window or globally for the entire application. The data can be pretty much whatever you want, from actual information to a hierarchy of WPF controls. This allows you to place data in one place and then use it from or several other places, which is very useful.The concept is used a lot for styles and templates.

<Window x:Class="WPFApplication.ResourceSample"
        Title="ResourceSample" Height="150" Width="350">
        <sys:String x:Key="strHelloWorld">Hello, world!</sys:String>
    <StackPanel Margin="10">
        <TextBlock Text="{StaticResource strHelloWorld}" FontSize="56" />
        <TextBlock>Just another "<TextBlock Text="{StaticResource strHelloWorld}" />" example, but with resources!</TextBlock>

enter image description here

Resources are given a key, using the x:Key attribute, which allows you to reference it from other parts of the application by using this key, in combination with the StaticResource markup extension. In this example, I just store a simple string, which I then use from two different TextBlock controls.

if you want to reproduce, please indicate the source:
WPF Resources – Hello Resources - CodeDay