Hi! While learning c# and wpf, i am trying to get grasp of data binding. So far unsuccessful. All the help i could find on the net, even if described as "for beginners", is too complicated for me to begin to understand. I would appreciate if someone can provide a code for binding in a very simple example:
namespace BindingTest
{
class TestClass
{
public int testProperty;
public TestClass()
{
testProperty = 10;
}
}
}
namespace BindingTest
{
public partial class Window1 : Window
{
TestClass iTestClass = new TestClass();
public Window1()
{
InitializeComponent();
}
private void buttonAdd10_Click(object sender, RoutedEventArgs e)
{
iTestClass.testProperty += 10;
}
}
}
<Window x:Class="BindingTest1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBox Height="25"
Margin="52,0,130,89"
Name="textBox1"
VerticalAlignment="Bottom"
/>
<Button Height="34"
HorizontalAlignment="Left"
Margin="38,40,0,0"
Name="buttonAdd10"
VerticalAlignment="Top"
Width="62"
Click="buttonAdd10_Click">
+10</Button>
</Grid>
</Window>
All I want to do is to bind textBox1.Text to iTestClass.testProperty, so that when I click the button I can see its value change in the textbox. What changes should be made in the code of this simple example in order to accomplish that?
If it is possible to be done without INotifyPropertyChanged, that is the way I wanna do it. Thank you in advance!
Vladimir