WPF sample

(Nothing new, codes taken from MSLearning)

<Application x:Class="MyApp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
Startup="MyApp_Startup"
Activated="MyApp_Activated"
Deactivated="MyApp_Deactivated"
SessionEnding="MyApp_SessionEnding"
Exit="MyApp_Exit"
</Application>





C#
public class MyApp : Application
{
StackPanel rootPanel;
Window win;

protected override void OnStartup(StartupEventArgs e)
{
win = new System.Windows.Window();
rootPanel = new StackPanel();
win.Content = rootPanel;
win.Show();
}

void MyApp_Startup (object sender, StartupEventArgs e)
{
//singleton model and where sharing information pages uses Properties.
MyApp.Current.Properties["TextFromPage1"] = txtBox.Text;

// Retrieve the information
string appPropertyValue;
appPropertyValue = (string)MyApp.Current.Properties["TextFromPage1"];

}

void MyApp_SessionEnding(object sender, SessionEndingCancelEventArgs e)
{
//trigger if user shut down system or log off and application hasn't exit.
//session ending then application exit
}


void MyApp_Activated(object sender, EventArgs e)
{

}

}

internal sealed class TestMain
{
[System.STAThread()]
public static void Main()
{
MyApp app = new MyApp();
app.Run();
}
}

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Tips on how to use IBM iNotes (web client) on emailing or scheduling - Like copy tables from Excel or checking for user id (windows logon id) through email address