Пример #1
0
		public void ForceSourceToNull ()
		{
			Person source = new Person { Age = 7 };
			TextBlock block = new TextBlock();
			block.SetBinding(TextBlock.TextProperty, new Binding {
				Path=new PropertyPath("Age"),
				Mode = BindingMode.TwoWay,
				TargetNullValue = "",
			});

			block.DataContext = source;
			block.Text = "";
			Assert.IsNull(source.Age, "#1");
		}
Пример #2
0
		static void Create(out Person source, out TextBlock target1, out TextBlock target2)
		{
			source = new Person { Age = 10 };
			target1 = new TextBlock();
			target2 = new TextBlock();

			target1.SetBinding(TextBlock.TextProperty, new Binding
			{
				FallbackValue = 99,
				Path = new PropertyPath("Age"),
				Mode = BindingMode.TwoWay,
				Source = source,
				StringFormat = "C",
				TargetNullValue = "66",
			});

			target2.SetBinding(TextBlock.TextProperty, new Binding
			{
				FallbackValue = 88,
				Path = new PropertyPath("Age"),
				Mode = BindingMode.TwoWay,
				Source = source,
				StringFormat = "C",
				TargetNullValue = "77",
			});
		}