I'm developing a XAML with C#, and I haven't programmed much with C#.
I am finding that the XAML scripting is coming along okay, but I am a little lost with the C#. I have designed an interface From with Tabs, Buttons, Text fields, Combo boxes etc, and now I am trying to write the C# event code behind the buttons, but I can't even write a command to get the From to close.
I have a few years experiences with C++, VBA, VB.net and Java etc, so I understand the command statements - "MessageBox.Show("HelloWorld");". However the code "private void cmdClose_Click(object sender, RoutedEventArgs e) {Page1().close;}" will not work for me and close my XAML form call "Page1". Why???
Loading
Mahesh ChandPosted Oct 13, 2009, 9:29 PM
Mick PichardPosted Oct 13, 2009, 6:00 PM
I'm a little confused though. Why "this.parent", I've seen/used the "this" command before in VB.net & C++ and understand it's referring to the current object and I can understand that your code is instructing the Parent of the current object to close, but why do you need to instruct the parent of the current object to close? Can you use the name of the object to want to close?
Like – "(frmAdmin as Window).Close();" or "(Page1 as Page).Close();"
Kirtan PatelPosted Oct 1, 2009, 11:08 AM
private void button1_Click(object sender, RoutedEventArgs e)
{
(this.Parent as Window).Close();
}