Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MyClass1 : Window
- {
- public MyClass2 MyClass2Object { get; set; }
- public MyClass1()
- {
- InitializeComponent();
- MyClass2Object = new MyClass2();
- Binding binding = new Binding();
- binding.Source = MyClass2Object;
- binding.Path = new PropertyPath("StringVar");
- TextBoxFromXaml.SetBinding(TextBox.TextProperty, binding);
- }
- }
- public class MyClass2
- {
- public string StringVar { get; set; }
- public MyClass2()
- {
- StringVar = "My String Here";
- }
- }
- public partial class Window1 : Window
- {
- public MyClass2 MyClass2Object { get; set; }
- public Window1()
- {
- // use data context instead of source
- DataContext = this;
- InitializeComponent();
- MyClass2Object = new MyClass2();
- Binding binding = new Binding();
- binding.Path = new PropertyPath("MyClass2Object.StringVar");
- TextBoxFromXaml.SetBinding(TextBox.TextProperty, binding);
- }
- }
- public class MyClass2
- {
- public string StringVar { get; set; }
- public MyClass2()
- {
- StringVar = "My String Here";
- }
- }
Add Comment
Please, Sign In to add comment