I am new to Xaml and binding concepts. How to bind the 'CustomerName' property of MainClass with text content of 'TextBox1' in XAML ?
Here is my MainClass,
namespace TextBinding.Module
{
public class MainClass
{
public string CustomerName { get; set; }
}
}
And my XAML coding is,
<UserControl x:Class="TextBinding.Design.ControlDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:TestControl="clr-namespace:TextBinding.Module"
mc:Ignorable="d" d:DesignHeight="1000" d:DesignWidth="1000">
<TestControl:MainClass x:Key="Test1" />
<Grid>
<TextBox x:Name="TextBox1" Height="50" Text="{Binding Test1.CustomerName, Mode=TwoWay}" />
</Grid>
</UserControl>
This above method is not working at all. Can anyone suggest a better way to bind.? Thanks in advance.