private void Button_Click_1(object sender, RoutedEventArgs e) { TextBlock mytext = new TextBlock(); container.Children.Add(mytext); mytext.FontSize = _fontSize; mytext.Foreground = _fontColor; mytext.Text = TextIn.Text; mytext.VerticalAlignment = System.Windows.VerticalAlignment.Center; mytext.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; mytext.SetValue(Canvas.TopProperty, (double)imgbk.GetValue(Canvas.HeightProperty)/2); mytext.SetValue(Canvas.LeftProperty, (double)imgbk.GetValue(Canvas.WidthProperty)/2); mytext.AddHandler(System.Windows.Controls.Button.MouseLeftButtonDownEvent, new MouseButtonEventHandler(Element_MouseLeftButtonDown), true); mytext.AddHandler(System.Windows.Controls.Button.MouseMoveEvent, new System.Windows.Input.MouseEventHandler(Element_MouseMove), true); mytext.AddHandler(System.Windows.Controls.Button.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Element_MouseLeftButtonUp), true); _myLstText.Add(mytext); }