-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (46 loc) · 1.94 KB
/
Program.cs
File metadata and controls
52 lines (46 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections.Generic;
using System.ComponentModel;
using ConsoleFramework;
using ConsoleFramework.Controls;
using ConsoleFramework.Core;
using ConsoleFramework.Events;
namespace Examples.MainMenu
{
class Program
{
// Example of binding menu item to command
private sealed class DataContext : INotifyPropertyChanged
{
public DataContext( ) {
command = new RelayCommand(
parameter => MessageBox.Show( "Information", "Command executed !", result => { } ),
parameter => true );
}
private readonly RelayCommand command;
public ICommand MyCommand {
get { return command; }
}
public event PropertyChangedEventHandler PropertyChanged;
}
public static void Main( string[ ] args ) {
WindowsHost windowsHost = ( WindowsHost ) ConsoleApplication.LoadFromXaml( "Examples.MainMenu.windows-host.xml", null );
DataContext dataContext = new DataContext( );
Window mainWindow = ( Window ) ConsoleApplication.LoadFromXaml(
"Examples.MainMenu.main.xml", dataContext );
windowsHost.Show( mainWindow );
// Example of direct subscribing to Click event
List< Control > menuItems = VisualTreeHelper.FindAllChilds( windowsHost.MainMenu, control => control is MenuItem );
foreach ( Control menuItem in menuItems ) {
MenuItem item = ( ( MenuItem ) menuItem );
if ( item.Title == "Go" ) {
item.Click += ( sender, eventArgs ) => {
MessageBox.Show( "", "", result => {
//
} );
};
}
}
ConsoleApplication.Instance.Run( windowsHost );
}
}
}