Inheritance: System.Windows.FrameworkElement
Example #1
0
		public void BindDpToDp_BindingExpressionType ()
		{
			// See what happens if we have a twoway binding of property type 'BindingExpressionBase'.
			// Normally the value would be copied to the datasource, but in this case we just replace
			// the existing twoway binding.
			var data = new TextProp { };
			var target = new TextProp { };

			var binding = target.SetBinding (TextProp.WidthProperty, new Binding {
				Mode = BindingMode.TwoWay,
				Path = new PropertyPath ("Opacity"),
				Source = new OpacityObject { Opacity = 0.5 },
			});

			target.ClearValue (TextProp.WidthProperty);
			target.SetBinding (TextProp.MyBindingExpressionProperty, new Binding {
				Source = data,
				Path = new PropertyPath ("MyBindingExpression"),
				Mode = BindingMode.TwoWay,
			});

			target.SetValue (TextProp.MyBindingExpressionProperty, binding);
			Assert.AreSame (binding, target.ReadLocalValue (TextProp.MyBindingExpressionProperty), "#1");
		}
Example #2
0
		public void BindToText5 ()
		{
			// Fails in Silverlight 3
			Binding binding = new Binding ("Prop");
			binding.Source = "string";
			TextProp prop = new TextProp ();
			prop.SetBinding (TextProp.MyTextProperty, binding);
			Assert.IsNull (prop.MyText, "#1");
		}
Example #3
0
		public void BindDpToDp ()
		{
			var data = new TextProp { MyText = "Hello" };
			TextBlock block = new TextBlock ();
			block.SetBinding (TextBlock.TextProperty,
				new Binding {
					Path = new PropertyPath ("MyText"),
					Mode = BindingMode.TwoWay,
					Source = data,
				}
			);

			Assert.AreEqual ("Hello", block.Text, "#1");

			data.MyText = "Yarr";
			Assert.AreEqual ("Yarr", block.Text, "#2");
		}