Пример #1
0
		public MainWindow ()
		{
			WidthRequest = 997;
			HeightRequest = 679;
			Title = "fkalc";

			var quitButton = new Button () { Content = new TextBlock() { Text = "Quit" }, BorderThickness = 0 };
			quitButton.Click += (sender, e) => Application.Current.Shutdown ();

			var fileMenuItem = new MenuItem ()
			{
				Header = new TextBlock()
				{
					Text = "File"
				},
				ItemsSource = new ObservableCollection<UIElement>()
				{ 
					new TextBlock() { Text = "New", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5) },
					new TextBlock() { Text = "Open", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)}, 
					new TextBlock() { Text = "Close", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)},
					new MenuItem() { Header = quitButton, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)},
				},
				Margin = new Thickness(5),
			};

			var menuItems = new ObservableCollection<MenuItem> () { fileMenuItem };

			var menu = new Menu ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch,
				ItemsSource = menuItems,
			};

			var tabControl = new TabControl ();
			tabControl.ItemTemplate = new DataTemplate (DocumentTemplate);

			BindingOperations.SetBinding (this, "DataContext.Documents", tabControl.GetProperty ("ItemsSource"));

			var grid = new Grid ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch
			};

			grid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
			grid.RowDefinitions.Add (new RowDefinition ());
			grid.ColumnDefinitions.Add (new ColumnDefinition ());

			grid.Children.Add (menu);
			grid.Children.Add (tabControl);		

			grid.SetRow (0, menu);
			grid.SetColumn (0, menu);

			grid.SetRow (1, tabControl);
			grid.SetColumn (0, tabControl);

			Content = grid;
		}
Пример #2
0
		public MainWindow ()
		{
			WidthRequest = 997;
			HeightRequest = 679;
			Title = "fkalc";

			var fileMenuItem = new MenuItem ()
			{
				Header = new TextBlock()
				{
					Text = "File"
				},
				ItemsSource = new ObservableCollection<UIElement>()
				{ 
					new TextBlock() { Text = "New", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5) },
					new TextBlock() { Text = "Open", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)}, 
					new TextBlock() { Text = "Close", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)}
				},
				//Template = new ControlTemplate(MenuItemTemplate),
				Margin = new Thickness(5),
			};

			var menuItems = new ObservableCollection<MenuItem> () { fileMenuItem };

			var menu = new Menu ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch,
				ItemsSource = menuItems,
			};

			var document = new DocumentView ()
			{
				DataContext = new DocumentViewModel ()
			};

			var grid = new Grid ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch
			};

			grid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
			grid.RowDefinitions.Add (new RowDefinition ());
			grid.ColumnDefinitions.Add (new ColumnDefinition ());

			grid.Children.Add (menu);
			grid.Children.Add (document);		

			grid.SetRow (0, menu);
			grid.SetColumn (0, menu);

			grid.SetRow (1, document);
			grid.SetColumn (0, document);

			Content = grid;
		}