/ Published in: C#
Expand |
Embed | Plain Text
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WPF_Testground { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); createTextBlock(); } public void createTextBlock() { tb.Text = "Eine Box"; binding.Source = bindingSource; tb.SetBinding(TextBlock.TextProperty, binding); grid.Children.Add(tb); } private void button1_Click(object sender, RoutedEventArgs e) { bindingSource.Wert++; } } class BindingSource : System.Windows.DependencyObject { public static System.Windows.DependencyProperty WertProperty; public BindingSource() { if (BindingSource.WertProperty == null) { } SetValue(BindingSource.WertProperty, 0); } public int Wert { get { return Int32.Parse(GetValue(BindingSource.WertProperty).ToString()); } set { SetValue(BindingSource.WertProperty, value); } } } }
You need to login to post a comment.
