Beispiel #1
0
		public void MentorTest_FrameworkElement_CollectionInCustomProperty_AttachOppositeOrder()
		{
			var mentor = new MentorElement();
			var collection = new DependencyObjectCollection<object>();
			var child = new SolidColorBrush();
			BindingOperations.SetBinding(child, SolidColorBrush.ColorProperty, new Binding());

			// Attach the child then the collection
			collection.Add(child);
			mentor.MentoredCollection = collection;

			mentor.DataContext = Colors.Red;
			Assert.AreEqual(Colors.Red, child.Color, "#1");
		}
Beispiel #2
0
		public void MentorTest_NotifyOnBindingException()
		{
			bool errored = false;
			var source = new INPC();
			var target = new CustomDependencyObject ();
			var mentor = new MentorElement { DataContext = source, MentoredCollection = new DependencyObjectCollection<object>() };
			mentor.MentoredCollection.Add(target);
			TestPanel.Children.Add(mentor);
			var binding = new Binding("SetterException") {
				Mode = BindingMode.TwoWay,
				ValidatesOnExceptions = true,
				NotifyOnValidationError = true
			};
			BindingOperations.SetBinding(target, CustomDependencyObject.WidthProperty, binding);
			Assert.AreEqual(100.0, target.Width, "#1");

			mentor.BindingValidationError += (o, e) => errored = true;
			Enqueue(() => {
				target.Width = 222;
				Assert.IsTrue(errored, "#2");
			});
			EnqueueTestComplete();
		}