Example #1
0
        public void TargetNullValueDoesTypeConvert_DataContext_NoPath()
        {
            bool invoked   = false;
            var  converter = new ManualConverter {
                ConvertFunc     = delegate { invoked = true; return(10.0); },
                ConvertBackFunc = delegate { invoked = true; return(10.0); },
            };

            var binding = new Binding {
                TargetNullValue = "100.00", FallbackValue = "50.00", Converter = converter
            };
            var rect = new Rectangle();

            rect.SetBinding(Rectangle.WidthProperty, binding);
            Assert.IsTrue(invoked, "#1");
            Assert.AreEqual(10, rect.Width, "#2");
        }
Example #2
0
        public void FallbackValueDoesNotTypeConvert()
        {
            bool invoked   = false;
            var  converter = new ManualConverter {
                ConvertFunc     = delegate { invoked = true; return(10.0); },
                ConvertBackFunc = delegate { invoked = true; return(10.0); },
            };

            var binding = new Binding("SomeProperty")
            {
                FallbackValue = "100.00", Converter = converter, Source = new object()
            };
            var rect = new Rectangle();

            rect.SetBinding(Rectangle.WidthProperty, binding);
            Assert.IsFalse(invoked, "#1");
            Assert.AreEqual(100, rect.Width, "#2");
        }
Example #3
0
		public void FallbackValueDoesNotTypeConvert ()
		{
			bool invoked = false;
			var converter = new ManualConverter {
				ConvertFunc = delegate { invoked = true; return 10.0; },
				ConvertBackFunc = delegate { invoked = true; return 10.0; },
			};

			var binding = new Binding ("SomeProperty") { FallbackValue = "100.00", Converter = converter, Source = new object () };
			var rect = new Rectangle ();
			rect.SetBinding (Rectangle.WidthProperty, binding);
			Assert.IsFalse (invoked, "#1");
			Assert.AreEqual (100, rect.Width, "#2");
		}
Example #4
0
		public void TargetNullValueDoesTypeConvert_DataContext_Path ()
		{
			bool invoked = false;
			var converter = new ManualConverter {
				ConvertFunc = delegate { invoked = true; return 10.0; },
				ConvertBackFunc = delegate { invoked = true; return 10.0; },
			};

			var binding = new Binding ("Test") { TargetNullValue = "100.00", FallbackValue = "50.00", Converter = converter };
			var rect = new Rectangle ();
			rect.SetBinding (Rectangle.WidthProperty, binding);
			Assert.IsFalse (invoked, "#1");
			Assert.AreEqual (50, rect.Width, "#2");
		}