首先对我的英语不好对不起。
我有一个关于tabcontrol的问题。 我有一个窗口,其中包含控件(按钮等)和2个框架。如果单击任何按钮框架,内容将更改为不同的页面。例如第1帧的第1页,第2帧的第2页。
第2页中的有一个tabcontrol,第1页中有过滤器按钮,tabcontrol显示数据并在第1页中单击按钮。Tabcontrol isenabled属性在加载窗口时为false,然后单击第1页中的任何按钮,isable属性为true,并显示数据没问题。
问题是,如果要单击page1中的“取消”按钮,我想将tabcontrol.isenabled属性设置为false,但是我不能这样做。我尝试了从第1页调用的第2页中的public方法,但是没有用。我尝试了委托和公共事件处理程序不起作用。这很奇怪,因为如果将代码放在第2页中的任何按钮单击事件中,它都可以工作,但是如果我在第2页中创建了方法,则将enable false代码放入其中,并且从第2页中的相同按钮单击事件中调用也无法正常工作。
第2页
<TabControl x:Name="tabC_Personel" x:FieldModifier="public" Margin="0,2,2,0" Grid.Row="2" Background="{x:Null}" Foreground="#FF2C436C" IsEnabled="{Binding}">
第1页
<Button x:Name="btn_formCLR" Content="Cancel" Grid.Column="4" Margin="4,0.8,3.8,1" BorderThickness="1" Foreground="White" Grid.Row="3" Background="#FF537293" BorderBrush="#FF34506E" Click="btn_formCLR_Click"/>
page1.cs
private void btn_formCLR_Click(object sender, RoutedEventArgs e)
{
page 2 f = new page 2();
f.cleaning();
f.tabC_Personel.IsEnabled = false;
}
page2.cs
void tt()
{
tabC_Personel.IsEnabled = false; //it is not working
MessageBox.Show("tt method"); // its working
}
public void cleaning()
{
tt();
}
谢谢。