-1
c
是一個具有一些屬性的對象,name是其中之一。我使用所選對象的名稱創建了一個文本塊。我試圖通過發送所有對象的信息跳轉到新頁面;我希望能夠在另一個窗口中獲取對象「c」的信息。發送對象信息到WPF中的另一個窗口C#
public MainWindow()
{
InitializeComponent();
}
private void b1_Click(object sender, RoutedEventArgs e)
{
TextBlock t1 = new TextBlock();
t1.Text = c.getName();
s1.Children.Add(t1);
Run run3 = new Run(c.getName());
Hyperlink hyperlink = new Hyperlink(run3)
{
NavigateUri = new Uri("http://stackoverflow.com")
};
hyperlink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(Hyperlink_RequestNavigate); //to be implemented
t1.Inlines.Clear();
t1.Inlines.Add(hyperlink);
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Window1 win1 = new Window1();
win1.Show();
this.Hide();
}
}
public Window1()
{
InitializeComponent();
//i want to obtain the object c here
Console.write(c.getName());
Console.write(c.getAddress());
Console.write(c.getPrice());
etc....
}
但現在我得到這個問題: 不一致的可訪問性:參數類型'ObjectC'比方法'Window1.Window1(ObjectC c)' – pMpC
確保'public'在你的ObjectC類聲明的前面 – axlj
謝謝你,它的工作! :d – pMpC