我有大問題Visual Studio wpf,當我嘗試發送任何字串時它不起作用我試圖寫public string str { set; get; }這個問題已經困擾了很長時間,我嘗試了很多使用歪曲的方法,但是程式或專案崩潰。
我正在使用 Visual Studio wpf c#
謝謝你的答案



public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
Info.Content = "Hello world";
}
private void button2_Click(object sender, RoutedEventArgs e)
{
Frame.Content = new Page1();
}
private void button2_MouseLeave(object sender, MouseEventArgs e)
{
Info.Content = "Label";
}
private void button1_MouseLeave(object sender, MouseEventArgs e)
{
Info.Content = "Label";
}
}
這里頁面類
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
MainWindow mw = new MainWindow();
mw.Info.Content = "Test Public";
}
}
uj5u.com熱心網友回復:
將 Page1 的 button1_MouseEnter 代碼更新為:
private void button1_MouseEnter(object sender, MouseEventArgs e)
{
MainWindow mw =Application.Current.Windows.Cast<Window>()
.FirstOrDefault(window=>window is MainWindow) as MainWindow;
mw.Info.Content = "Test Public";
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/416505.html
標籤:
