Actually, I'm using C# with WPF. Let me explain again:
I have create UserControl (WPF) with one Button (Click on Button to create Image and textBox (Like New Folder)).
And I have another Window form (WPF) with Button and I want to Click on Button in Window Form to do Action instead of Button in UserControl. Here is the code of UserControl:
private void btnNewRoom_Click(object sender, RoutedEventArgs e)
{
Image img = new Image();
img.VerticalAlignment = System.Windows.VerticalAlignment.Top;
img.Width = 100;
img.Height = 100;
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
var applicationDirectory = System.IO.Path.GetDirectoryName(assemblyLocation);
img.Source = new BitmapImage(new Uri("/Resources/Images/folder.png", UriKind.RelativeOrAbsolute));
StackPanel sp = new StackPanel();
TextBox tb = new TextBox();
tb.Width = 120;
tb.Height = 25;
tb.Text = "New Folder";
sp.Children.Add(img);
sp.Children.Add(tb);
AddNewRoom.Children.Add(sp);
}
and It is possible ?
Note: Any good way to Click button to Create Image and TextBox?
在WPF控件中实现静态事件处理程序,只需从Window Form的按钮click事件中调用它即可。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.