Exemple #1
0
        public void DataBinding_BindToBooleanMember()
        {
            ThreadRunner.RunInSTA(delegate {
                //Create the visual
                BoolToVisibilityConverterTestVisual testVisual = new BoolToVisibilityConverterTestVisual();

                //Create the object that the visual will databind to.
                BoolToVisibilityConverterBindableBoolClass dataContext = new BoolToVisibilityConverterBindableBoolClass();
                dataContext.IsVisible1 = true;
                dataContext.IsVisible2 = true;
                testVisual.DataContext = dataContext;

                //Render the visual
                RenderUtility.RenderVisual(testVisual);

                //Check the visibility of the controls
                Assert.IsTrue(testVisual.nonInvertingVisibilityControl.Visibility == Visibility.Visible);
                Assert.IsTrue(testVisual.invertingVisibilityControl.Visibility == Visibility.Collapsed);

                //Negate the visibilities to check that ConvertBack works ok.
                testVisual.NegateCurrentVisbilities();
                RenderUtility.RenderVisual(testVisual);

                //Check the visibility flags in our datacontext
                Assert.IsTrue(dataContext.IsVisible1 == false);
                Assert.IsTrue(dataContext.IsVisible2 == false);
            });
        }
Exemple #2
0
        public void DataBinding_BindToNonBooleanMember()
        {
            ThreadRunner.RunInSTA(delegate
            {
                //Create the visual
                BoolToVisibilityConverterTestVisual testVisual = new BoolToVisibilityConverterTestVisual();

                //Create the object that the visual will databind to.
                BoolToVisibilityConverterBindableNonBoolClass dataContext = new BoolToVisibilityConverterBindableNonBoolClass();
                dataContext.IsVisible1 = "some string 1";
                dataContext.IsVisible2 = "some string 2";
                testVisual.DataContext = dataContext;

                //Render the visual
                RenderUtility.RenderVisual(testVisual);
            });
        }