I've got MainWindow in my WPF project, into this class there is a Frame.
我的WPF项目中有MainWindow,这个类中有一个Frame。
<Window x:Class="Gestionale.MainWindow>
<Grid>
<Frame x:Name="frameChanger"/>
<Button x:Name="Prenotation"/>
</Grid>
</Window>
When I click the button Add the frame shows the page Prenotation with this function:
当我单击按钮添加框架时,显示具有此功能的页面Prenotation:
public partial class MainWindow : Window
{
private void Add_Click(object sender, RoutedEventArgs e)
{
enabled_button();
camereButton.IsEnabled = false;
try
{
frameChanger.Navigate(new framePrenotation());
}
catch(Exception ex) { MessageBox.Show("Error!"); }
}
}
The page prenotation has other 3 button:
页面前缀有其他3个按钮:
<Page x:Name="Gestionale.AddPrenotation">
<Grid>
<Button x:Name="DeletePrenotation"/>
<Button x:Name="AlterPrenotation"/>
<Button x:Name="AddPrenotation"/>
</Grid>
</Page>
I need the frameChanger references to AddPrenotation page when I click on "AddPrenotation". How can I do it?
当我点击“AddPrenotation”时,我需要frameChanger引用AddPrenotation页面。我该怎么做?
Any guidance will be appreciated
任何指导将不胜感激
Thanks, Davide
1 个解决方案
#1
0
try to write a constructor with parameter into the Page
尝试将带有参数的构造函数写入Page
frameChanger.Navigate(new framePrenotation(frameChanger));`
...
public partial class framePrenotation: Page
{
private Frame frameParent;
public framePrenotation(Frame frame)
{
this.frameParent= frame;
...
}
...
}
but I don't see why you should do something like that...
但我不明白你为什么要这样做......
#1
0
try to write a constructor with parameter into the Page
尝试将带有参数的构造函数写入Page
frameChanger.Navigate(new framePrenotation(frameChanger));`
...
public partial class framePrenotation: Page
{
private Frame frameParent;
public framePrenotation(Frame frame)
{
this.frameParent= frame;
...
}
...
}
but I don't see why you should do something like that...
但我不明白你为什么要这样做......