更新选项卡控制来自另一个类的wpf [英] update tab control wpf from another class
本文介绍了更新选项卡控制来自另一个类的wpf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早上好
我有两节课
1级Window1:包含添加的标签控件
2级DesignerCanvas:必须在选项卡控件中添加文本
然后我在类DesignerCanvas中添加以下代码
good morning
I have two class
1-class Window1 : that contains the tab control added
2-class DesignerCanvas :must add a text in tab control
I then add the following code in the class DesignerCanvas
public Window1 form;
public DesignerCanvas(Window1 form)
{
this.form = form;
}
public void SendBackward_Executed( object sender, ExecutedRoutedEventArgs e)
{
((Window1)form).tabItem1.Content = "new text" ;
}
在类window1中我添加以下代码
In class window1 I add the following code
private DesignerCanvas test = new DesignerCanvas();
和方法public window1我添加:
and in the method public window1 I add:
public Window1()
{
InitializeComponent();
test.form = this;
//here is the error
test.SendBackward_Executed(object sender , System.Windows.Input.ExecutedRoutedEventArgs e);
}
有没有其他方法可以调用方法?
is there any other way to call the method??
推荐答案
即使前两行代码也不会编译,因为第一行中有一些代码垃圾。从代码中删除乱码,然后提出问题。但是从其他类中调用任何东西都没有任何麻烦:它只是访问修饰符的问题,更重要的是,正确设计代码。
-SA
Even the first two lines of code won''t compile, due to some code garbage in a very first line. Remove gibberish from the code and then ask a question. But there are no any hassles to call anything from "other class": it''s just the matter of access modifiers and, more importantly, proper design of the code.
—SA
这篇关于更新选项卡控制来自另一个类的wpf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文