Exemplo n.º 1
0
Arquivo: Main.cs Projeto: mhusen/Eto
		public MyForm()
		{
			ClientSize = new Size(600, 400);
			Title = "Table Layout";


			Content = new TableLayout(
				new TableRow(new Label { Text = "DataContext Binding" }, DataContextBinding()),
				new TableRow(new Label { Text = "Object Binding" }, ObjectBinding()),
				new TableRow(new Label { Text = "Direct Binding" }, DirectBinding()),
				null // same as creating a row with ScaleHeight = true
			) { Spacing = new Size(5, 5), Padding = new Padding(10) };

			// Set data context so it propegates to all child controls
			DataContext = new MyObject { TextProperty = "Initial value 1" };

			Menu = new MenuBar
			{
				QuitItem = new Command((sender, e) => Application.Instance.Quit())
				{ 
					MenuText = "Quit",
					Shortcut = Application.Instance.CommonModifier | Keys.Q
				}
			};
		}
Exemplo n.º 2
0
Arquivo: Main.cs Projeto: mhusen/Eto
		TextBox ObjectBinding()
		{
			// object instance we want to bind to
			var obj = new MyObject { TextProperty = "Initial value 2" };

			var textBox = new TextBox();
			// bind to the text property of a specific object instance using reflection
			textBox.TextBinding.Bind(obj, r => r.TextProperty);
			return textBox;
		}