Exemplo n.º 1
0
        /// <summary>
        /// Initializes the views and set the bindings
        /// </summary>
        private void Initialize()
        {
            var heightBinding = ViewUtils.CreateBinding(this.DataContext, "Height");

            BindingOperations.SetBinding(this, HeightProperty, heightBinding);

            var widthBinding = ViewUtils.CreateBinding(this.DataContext, "Width");

            BindingOperations.SetBinding(this, WidthProperty, widthBinding);

            var xPosBinding = ViewUtils.CreateBinding(this.DataContext, "Position");

            BindingOperations.SetBinding(this, PositionProperty, xPosBinding);

            var contentBinding = ViewUtils.CreateBinding(this.DataContext, "Thing.DepictedThing", BindingMode.OneWay);

            BindingOperations.SetBinding(this, ContentObjectProperty, contentBinding);

            this.Shape   = Cdp4DiagramHelper.GetShape(((IDiagramObjectViewModel)this.DataContext).Thing.DepictedThing.ClassKind);
            this.Content = this.ContentObject.UserFriendlyShortName;

            var parent = (Cdp4DiagramControl)this.behaviour.AssociatedObject;

            this.Template = (ControlTemplate)parent.FindResource("DiagramObjectTemplate");
            // TODO Set Style
        }
        public void VerifyThatPropertiesOfBindingAreSet()
        {
            var dataContext = new object();
            var path        = "PropertyName";

            var binding = ViewUtils.CreateBinding(dataContext, path, BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged);

            Assert.AreEqual(dataContext, binding.Source);
            Assert.IsNotNull(binding.Path);
            Assert.AreEqual(BindingMode.TwoWay, binding.Mode);
            Assert.AreEqual(UpdateSourceTrigger.PropertyChanged, binding.UpdateSourceTrigger);
        }
        /// <summary>
        /// Initializes the component
        /// </summary>
        private void Initialize()
        {
            var sourceBinding = ViewUtils.CreateBinding(this.DataContext, "Source");

            BindingOperations.SetBinding(this, SourceProperty, sourceBinding);

            var targetBinding = ViewUtils.CreateBinding(this.DataContext, "Target");

            BindingOperations.SetBinding(this, TargetProperty, targetBinding);

            var textBinding = ViewUtils.CreateBinding(this.DataContext, "DisplayedText", BindingMode.OneWay);

            BindingOperations.SetBinding(this, ContentProperty, textBinding);

            var connectingPointsBinding = ViewUtils.CreateBinding(this.DataContext, "ConnectingPoints");

            BindingOperations.SetBinding(this, ConnectionPointsProperty, connectingPointsBinding);

            this.CanMove = false;
        }
        public void VerifyThatIfPathIsNullOrWhiteSpaceExceptionIsThrown()
        {
            var dataContext = new object();

            Assert.Throws <ArgumentNullException>(() => ViewUtils.CreateBinding(dataContext, null, BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged));
        }
 public void VerifyThatIfDataContextIsNullArgumentExceptionIsThrown()
 {
     Assert.Throws <ArgumentNullException>(() => ViewUtils.CreateBinding(null, null, BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged));
 }