Resources are objects referred in WPF XAML. In C# code when we create an object we do the following three steps :-
using CustomerNameSpace; // import the namespace.
Customer obj = new Customer(); // Create object of the class
Textbox1.text = obj.CustomerCode; // Bind the object with UI elements
So even in WPF XAML to define resources which are nothing but objects we need to the above 3 steps :-
<Window x:Class="LearnWpfResources.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:custns="clr-namespace:LearnWpfResources" Title="MainWindow" Height="350" Width="525">
<Window.Resources> <custns:Customer x:Key="custobj"/> </Window.Resources>
The above code you can map to something like this in C#
Customer custobj = new Customer();
<TextBox Text="{Binding CustomerCode, Mode=TwoWay, Source={StaticResource custobj}}" />