将(WPF窗口)按钮动作链接到其他(WPF窗口)堆栈面板? [英] Linking (WPF window) button action to other (WPF window) stackpanel?
问题描述
我有两个窗户.我想知道是否可以将Window1中按钮的操作链接到MainWindow中的堆栈面板.
例如Window1中的按钮是否应向MainWindow堆栈面板添加1个矩形?
只需要一个提示或一些东西就可以了. Havent之前曾尝试在两个单独的窗口之间链接按钮和其他堆栈面板.
我正在用C#编程.
例如:
该代码用于Window1中的button1 :(这只是代码的一部分):
I have two windows. I am wondering if it is possible to link the action of a button in Window1 to a stackpanel which is in th MainWindow.
Such as the button in Window1 should add 1 rectangle to the MainWindow stackpanel?
Just need a hint or something to go on. Havent tried linking buttons and other stackpanels between two seperate windows before.
I am programming in C#.
eg:
this code is for button1 in Window1: (this is just part of the code):
private void button1_Click(object sender, RoutedEventArgs e)
{
string tempDisks = comboBox.Text;
if (tempDisks == "1")
{
stackPanel1.Children.Add(rectangle1);
}
}
MainpanWindow中的stackpanel1所在的位置.
感谢任何回答
Where stackpanel1 is in the MainWindow.
Thanx for any responses
推荐答案
furyous已经回答了这个问题.
furyous already answered this question.
public partial class SecWindow : Window
{
private MainWindow m_Parent;
public SecWindow(MainWindow parent)
{
InitializeComponent();
m_Parent = parent;
m_Parent.FunctionCall();
}
}
这篇关于将(WPF窗口)按钮动作链接到其他(WPF窗口)堆栈面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!