Inheritance: IMarkupExtension, IExpressionProvider
        public HumanMacroDialog(Word.Range text, int jobNumber)
        {
            this.text = text;
            this.jobNumber = jobNumber;
            InitializeComponent();

            Binding binding = new Binding();
            binding.Source = text;
            binding.Path = new PropertyPath("Text");
            textToWorkWith.SetBinding(TextBox.TextProperty, binding);

            numItems.Content = numSections + " paragraph" + (numSections == 1 ? "" : "s") + " selected, each as a separate task";

            item1 = new ComboBoxItem();
            item1.Content = "Paragraph";
            item2 = new ComboBoxItem();
            item2.Content = "Sentence";

            separatorBox.Items.Add(item1);
            separatorBox.Items.Add(item2);
            separatorBox.SelectedValue = item1;

            returnAsComments = new ComboBoxItem();
            returnAsComments.Content = "Comments";
            returnAsInline = new ComboBoxItem();
            returnAsInline.Content = "In-Line Changes";
            returnTypeBox.Items.Add(returnAsComments);
            returnTypeBox.Items.Add(returnAsInline);
            returnTypeBox.SelectedValue = returnAsComments;
        }
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var selectedItem = (DataContext as IEntityGridViewModel).SelectedItem;

            if (selectedItem == null)
                return;

                Type type = selectedItem.GetType();
            var relationshipProperties = type.GetProperties()
             .Where(t =>
                     t.Name != "Relationships" &&
                     t.GetGetMethod().IsVirtual &&
                     t.PropertyType.IsGenericType &&
                     t.PropertyType.GetGenericTypeDefinition() == typeof(ICollection<>))
             .ToList();

            foreach (var property in relationshipProperties)
            {
                //Binding binding = new Binding() { Path = new PropertyPath("SelectedItem." + property.Name), Source = this.DataContext };

                TextBlock textBlock = new TextBlock() { Text = property.Name };
                //BindingOperations.SetBinding(textBlock, TextBlock.TextProperty, binding);

                relatedEntitiesStackPanel.Children.Add(textBlock);

                Binding binding = new Binding() { Path = new PropertyPath("SelectedItem." + property.Name), Source = this.DataContext };

                DataGridControl listView = new DataGridControl();
                var value = property.GetValue(selectedItem) as System.Collections.IEnumerable;
                //listView.ItemsSource = value;
                BindingOperations.SetBinding(listView, DataGrid.ItemsSourceProperty, binding);

                relatedEntitiesStackPanel.Children.Add(listView);
            }
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var progressIndicator = SystemTray.ProgressIndicator;
                if (progressIndicator != null)
                {
                    return;
                }

                progressIndicator = new ProgressIndicator();

                SystemTray.SetProgressIndicator(this, progressIndicator);

                Binding binding = new Binding("IsLoading") { Source = _viewModel };
                BindingOperations.SetBinding(
                    progressIndicator, ProgressIndicator.IsVisibleProperty, binding);

                binding = new Binding("IsLoading") { Source = _viewModel };
                BindingOperations.SetBinding(
                    progressIndicator, ProgressIndicator.IsIndeterminateProperty, binding);

                progressIndicator.Text = "Loading games...";
                _viewModel.LoadPage(lastPagePulled, PAGE_COUNT);
                lastPagePulled += 1;
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
            }
        }
        public static void SetBindingObject(FrameworkElement obj, BindingMode mode, object source, DependencyProperty dp, string propertyName)
        {
            Type propertyType = source.GetType().GetProperty(propertyName).PropertyType;
            PropertyInfo info = source.GetType().GetProperty("RangeList");
            FANumberRangeRule rangeRule = null;
            if (info != null)
            {
                object value = info.GetValue(source, null);
                if (value != null)
                {
                    FALibrary.Utility.SerializableDictionary<string, FARange> dic =
                        (FALibrary.Utility.SerializableDictionary<string, FARange>)value;
                    if (dic.ContainsKey(propertyName))
                    {
                        rangeRule = new FANumberRangeRule(propertyType);
                        rangeRule.Range = dic[propertyName];
                        obj.Tag = rangeRule;
                        obj.Style = (Style)App.Current.Resources["TextBoxErrorStyle"];
                    }
                }
            }

            Binding bd = new Binding(propertyName);
            bd.Source = source;
            bd.Mode = mode;
            bd.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            if (rangeRule != null)
            {
                bd.NotifyOnValidationError = true;
                bd.ValidationRules.Add(rangeRule);
            }

            obj.SetBinding(dp, bd);
        }
		public static void SetBinding ( 
			DependencyObject target, 
			DependencyProperty property,
			Binding binding ) {

			throw new NotImplementedException ( );
		}
        public IntegerSlider(Core.VplControl hostCanvas)
            : base(hostCanvas)
        {
            AddOutputPortToNode("Number", typeof(int));

            SliderExpanderInteger expander = new SliderExpanderInteger
            {
                Style = hostCanvas.FindResource("ExpanderSliderStyleInteger") as Style,
                SliderValue = 5,
                SliderMax = 10,
                SliderMin = 0,
                SliderStep = 1
            };

            var b2 = new Binding("Data")
            {
                Mode = BindingMode.OneWayToSource,
                Source = OutputPorts[0]
            };
            expander.SetBinding(SliderExpanderInteger.SliderValueProperty, b2);

            Name = "Integer slider";

            AddControlToNode(expander);
        }
        public override string ToString()
        {
            s = (Rand)base.Tag;

            Binding myBinding = new Binding("result");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = s;
            txtres.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("min");
            myBinding2.Mode = BindingMode.TwoWay;
            myBinding2.Source = s;
            txtmin.SetBinding(TextBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("max");
            myBinding3.Mode = BindingMode.TwoWay;
            myBinding3.Source = s;
            txtmax.SetBinding(TextBox.TextProperty, myBinding3);

            Binding descbinding = new Binding("Description");
            descbinding.Mode = BindingMode.TwoWay;
            descbinding.Source = s;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);

            return base.ToString();
        }
        public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu)
        {
            var buttonHolder = widgetViewModel as EntityButtonWidgetViewModel;

            var ret = new FlexButton.FlexButton { DataContext = buttonHolder, ContextMenu = contextMenu, CommandParameter = buttonHolder };

            var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var captionBinding = new Binding("Settings.Caption") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var commandBinding = new Binding("ItemClickedCommand") { Source = buttonHolder, Mode = BindingMode.OneWay };
            var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay };
            var rotateTransform = new Binding("RotateTransform") { Source = buttonHolder, Mode = BindingMode.OneWay };

            ret.SetBinding(InkCanvas.LeftProperty, xBinding);
            ret.SetBinding(InkCanvas.TopProperty, yBinding);
            ret.SetBinding(FrameworkElement.HeightProperty, heightBinding);
            ret.SetBinding(FrameworkElement.WidthProperty, widthBinding);
            ret.SetBinding(ContentControl.ContentProperty, captionBinding);
            ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding);
            ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding);
            ret.SetBinding(ButtonBase.CommandProperty, commandBinding);
            ret.SetBinding(FrameworkElement.LayoutTransformProperty, rotateTransform);
            //ret.SetBinding(UIElement.IsEnabledProperty, enabledBinding);

            return ret;
        }
        public override string ToString()
        {
            g = (SayUnixTime)base.Tag;

            Binding myBinding = new Binding("unixtime");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = g;
            txttime.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("timezone");
            myBinding2.Mode = BindingMode.TwoWay;
            myBinding2.Source = g;
            txttz.SetBinding(TextBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("format");
            myBinding3.Mode = BindingMode.TwoWay;
            myBinding3.Source = g;
            txtformat.SetBinding(TextBox.TextProperty, myBinding3);


            Binding descbinding = new Binding("Description");
            descbinding.Mode = BindingMode.TwoWay;
            descbinding.Source = g;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);

            return base.ToString();
        }
Beispiel #10
1
        private void AsymmetricObjects()
        {
            Console.WriteLine("Asymmetric");
            Console.WriteLine("----------");

            // bind
            var numberBinding = new Binding("Number") {Source = _guineaPig};
            var nameBinding = new Binding("FullName") {Source = _guineaPig};
            _subjectUnderTest.Number.SetBinding(System.Windows.Controls.TextBox.TextProperty, numberBinding);
            _subjectUnderTest.FullName.SetBinding(System.Windows.Controls.TextBox.TextProperty, nameBinding);

            var testDuration = new Stopwatch();
            testDuration.Start();
            RunAsymmetric();
            testDuration.Stop();
            Console.WriteLine(
                string.Format("Write to {0}: {1} msec.", _subjectUnderTest.GetType().Name, testDuration.ElapsedMilliseconds.ToString("#,###")));

            testDuration.Restart();
            RunReverseAsymmetric();
            testDuration.Stop();
            Console.WriteLine(
                string.Format("Write to {0}: {1} msec.", _guineaPig.GetType().Name, testDuration.ElapsedMilliseconds.ToString("#,###")));

            Console.WriteLine();
        }
		public MemberPickerDlg(IFileTreeView globalFileTreeView, IFileTreeView newFileTreeView, IImageManager imageManager) {
			InitializeComponent();
			DataContextChanged += (s, e) => {
				var data = DataContext as MemberPickerVM;
				if (data != null) {
					data.OpenAssembly = new OpenAssembly(globalFileTreeView.FileManager);
					data.PropertyChanged += MemberPickerVM_PropertyChanged;
				}
			};
			openImage.Source = imageManager.GetImage(GetType().Assembly, "Open", BackgroundType.DialogWindow);

			var treeView = (Control)newFileTreeView.TreeView.UIObject;
			cpTreeView.Content = treeView;
			Validation.SetErrorTemplate(treeView, (ControlTemplate)FindResource("noRedBorderOnValidationError"));
			treeView.AllowDrop = false;
			treeView.BorderThickness = new Thickness(1);

			var binding = new Binding {
				ValidatesOnDataErrors = true,
				ValidatesOnExceptions = true,
				UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
				Path = new PropertyPath("SelectedItem"),
				Mode = BindingMode.TwoWay,
			};
			treeView.SetBinding(Selector.SelectedItemProperty, binding);

			var cmd = new RelayCommand(a => {
				searchTextBox.SelectAll();
				searchTextBox.Focus();
			});
			InputBindings.Add(new KeyBinding(cmd, Key.E, ModifierKeys.Control));
			InputBindings.Add(new KeyBinding(cmd, Key.F, ModifierKeys.Control));
		}
		public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource)
		{
			var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock));
			var binding = new sw.Data.Binding { Path = TextPath, RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged };
			factory.SetBinding(EditableTextBlock.TextProperty, binding);
			return factory;
		}
Beispiel #13
1
 public AutoScrollHandler(System.Windows.Controls.ListBox target)
 {
     Target = target;
     Binding B = new Binding("ItemsSource");
     B.Source = Target;
     BindingOperations.SetBinding(this, ItemsSourceProperty, B);
 }
Beispiel #14
1
        private void UpdateContent()
        {
            if (panel == null)
                return;

            panel.Children.Clear();
            
            if (Value == null)
                return;
            
            var enumValues = Enum.GetValues(Value.GetType()).FilterOnBrowsableAttribute();
            var converter = new EnumToBooleanConverter { EnumType = Value.GetType() };
            var relativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(RadioButtonList), 1);
            var descriptionConverter = new EnumDescriptionConverter();

            foreach (var itemValue in enumValues )
            {
                var rb = new RadioButton { Content = descriptionConverter.Convert(itemValue, typeof(string), null, CultureInfo.CurrentCulture) };
                // rb.IsChecked = Value.Equals(itemValue);

                var isCheckedBinding = new Binding("Value")
                                           {
                                               Converter = converter,
                                               ConverterParameter = itemValue,
                                               Mode = BindingMode.TwoWay,
                                               RelativeSource = relativeSource
                                           };
                rb.SetBinding(ToggleButton.IsCheckedProperty, isCheckedBinding);

                var itemMarginBinding = new Binding("ItemMargin") { RelativeSource = relativeSource };
                rb.SetBinding(MarginProperty, itemMarginBinding);

                panel.Children.Add(rb);
            }
        }
        public override string ToString()
        {
            g = (ExtenSpy)base.Tag;

            Binding myBinding = new Binding("extension");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = g;
            txtext.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("context");
            myBinding2.Mode = BindingMode.TwoWay;
            myBinding2.Source = g;
            txtcontext.SetBinding(TextBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("options");
            myBinding3.Mode = BindingMode.TwoWay;
            myBinding3.Source = g;
            txtopt.SetBinding(TextBox.TextProperty, myBinding3);


            Binding descbinding = new Binding("Description");
            descbinding.Mode = BindingMode.TwoWay;
            descbinding.Source = g;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);


            return base.ToString();
        }
Beispiel #16
1
        public void SetupTargetBinding(FrameworkElement targetObject)
        {
            if (targetObject == null)
            {
                return;
            }

            // Prevent the designer from reporting exceptions since
            // changes will be made of a Binding in use if it is set
            if (DesignerProperties.GetIsInDesignMode(this) == true)
                return;

            // Bind to the selected TargetProperty, e.g. ActualHeight and get
            // notified about changes in OnTargetPropertyListenerChanged
            var listenerBinding = new Binding
            {
                Source = targetObject,
                Path = new PropertyPath(TargetProperty),
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(this, TargetPropertyListenerProperty, listenerBinding);

            // Set up a OneWayToSource Binding with the Binding declared in Xaml from
            // the Mirror property of this class. The mirror property will be updated
            // everytime the Listener property gets updated
            BindingOperations.SetBinding(this, TargetPropertyMirrorProperty, Binding);
            TargetPropertyValueChanged();
        }
Beispiel #17
1
        /// <summary>
        /// Initializes a new instance of the <see cref="WatermarkAdorner"/> class
        /// </summary>
        /// <param name="adornedElement"><see cref="UIElement"/> to be adorned</param>
        /// <param name="watermark">The watermark</param>
        public WatermarkAdorner(UIElement adornedElement, object watermark)
            : base(adornedElement)
        {
            IsHitTestVisible = false;

            contentPresenter = new ContentPresenter
            {
                Content = watermark,
                Opacity = 0.5,
                Margin = new Thickness(Control.Margin.Left + Control.Padding.Left, Control.Margin.Top + Control.Padding.Top, 0, 0)
            };

            if (Control is ItemsControl && !(Control is ComboBox))
            {
                contentPresenter.VerticalAlignment = VerticalAlignment.Center;
                contentPresenter.HorizontalAlignment = HorizontalAlignment.Center;
            }

            // Hide the control adorner when the adorned element is hidden
            var binding = new Binding("IsVisible")
            {
                Source = adornedElement,
                Converter = new BooleanToVisibilityConverter()
            };
            SetBinding(VisibilityProperty, binding);
        }
Beispiel #18
1
        public BaseBox()
        {
            // テキストボックスの高さを固定
            this.Height = 23;
            // 文字の垂直方向の配置
            this.VerticalContentAlignment = VerticalAlignment.Center;
            // 折り返し表示の禁止
            this.TextWrapping = System.Windows.TextWrapping.NoWrap;
            // Enterによるフォーカス移動
            this.SetValue(EnterThenNextFocus.EnterThenNextFocusProperty, true);
            // フォーカス取得時にテキスト全選択
            this.SetValue(SelectOnFocus.SelectOnFocusProperty, true);

            // バインディングなどの設定
            this.Initialized += delegate
            {
                // エラー発生時の表示テンプレートの設定
                ControlTemplate ErrTemplate = (ControlTemplate)FindResource("ErrTemplate");
                this.SetValue(Validation.ErrorTemplateProperty, ErrTemplate);

                // バインディングの設定
                Binding oldBinding = BindingOperations.GetBinding(this, TextBox.TextProperty);
                if (oldBinding == null) return;
                BindingOperations.ClearBinding(this, TextBox.TextProperty);
                Binding newBinding = new Binding(oldBinding.Path.Path)
                {
                    StringFormat = DisplayFormat.GetDisplayFormat(this),
                    Mode = BindingMode.TwoWay,
                    TargetNullValue = String.Empty
                };
                BindingOperations.SetBinding(this, TextBox.TextProperty, newBinding);
            };
        }
        public Comment(Node hostNode)
        {
            HostNode = hostNode;

            var scrollViewer = new ScrollViewer
            {
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
                Height = 70,
                CanContentScroll = true
            };

            var textBlock = new TextBlock
            {
                Background = Brushes.Transparent,
                TextWrapping = TextWrapping.Wrap,
                Margin = new Thickness(5),
                FontSize = 12
            };

            Child = scrollViewer;
            CornerRadius = new CornerRadius(5);
            scrollViewer.Content = textBlock;


            var bindingTextToTextBlock = new Binding("Text")
            {
                Source = this,
                Mode = BindingMode.OneWay
            };
            textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock);

            hostNode.SpaceCanvas.Children.Add(this);
        }
Beispiel #20
1
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class. 
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();

            // initialize the sensor chooser and UI
            this.sensorChooser = new KinectSensorChooser();
            this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
            this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
            this.sensorChooser.Start();

            // Bind the sensor chooser's current sensor to the KinectRegion
            var regionSensorBinding = new Binding("Kinect") { Source = this.sensorChooser };
            BindingOperations.SetBinding(this.kinectRegion, KinectRegion.KinectSensorProperty, regionSensorBinding);

            // Clear out placeholder content
            this.wrapPanel.Children.Clear();

            // Add in display content
            for (var index = 0; index < 300; ++index)
            {
                var button = new KinectTileButton { Label = (index + 1).ToString(CultureInfo.CurrentCulture) };
                this.wrapPanel.Children.Add(button);
            }

            // Bind listener to scroll viewer scroll position change, and check scroll viewer position
            this.UpdatePagingButtonState();
            scrollViewer.ScrollChanged += (o, e) => this.UpdatePagingButtonState();
        }
        public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu)
        {
            var buttonHolder = widgetViewModel as TicketExplorerViewModel;

            var ret = new TicketExplorerView { DataContext = buttonHolder, ContextMenu = contextMenu };

            var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay };
            var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay };

            ret.SetBinding(InkCanvas.LeftProperty, xBinding);
            ret.SetBinding(InkCanvas.TopProperty, yBinding);
            ret.SetBinding(FrameworkElement.HeightProperty, heightBinding);
            ret.SetBinding(FrameworkElement.WidthProperty, widthBinding);
            //ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding);
            //ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding);
            //ret.SetBinding(UIElement.RenderTransformProperty, transformBinding);
            //ret.SetBinding(UIElement.IsEnabledProperty, enabledBinding);

            return ret;
        }
Beispiel #22
1
 internal static void SetBinding(this DependencyObject sourceObject, DependencyObject targetObject, DependencyProperty sourceProperty, DependencyProperty targetProperty)
 {
     Binding b = new Binding();
     b.Source = sourceObject;
     b.Path = new PropertyPath(sourceProperty);
     BindingOperations.SetBinding(targetObject, targetProperty, b);
 }
        /// <summary>
        /// Creates a new <see cref="Binding"/> object by copying all properties
        /// from another <see cref="Binding"/> object.
        /// </summary>
        /// <param name="binding"><see cref="Binding"/> from which property values will be copied</param>
        /// <returns>A new <see cref="Binding"/> object.</returns>
        public static Binding CreateCopy(this Binding binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            Binding newBinding = new Binding()
            {
                BindsDirectlyToSource = binding.BindsDirectlyToSource,
                Converter = binding.Converter,
                ConverterParameter = binding.ConverterParameter,
                ConverterCulture = binding.ConverterCulture,
                Mode = binding.Mode,
                NotifyOnValidationError = binding.NotifyOnValidationError,
                Path = binding.Path,
                UpdateSourceTrigger = binding.UpdateSourceTrigger,
                ValidatesOnExceptions = binding.ValidatesOnExceptions
            };

            if (binding.ElementName != null)
            {
                newBinding.ElementName = binding.ElementName;
            }
            else if (binding.RelativeSource != null)
            {
                newBinding.RelativeSource = binding.RelativeSource;
            }
            else
            {
                newBinding.Source = binding.Source;
            }

            return newBinding;
        }
        public InkCanvasAnnotationControl(
            InkCanvasAnnotation InkCanvasAnnotation)
        {
            InitializeComponent();

            if (InkCanvasAnnotation == null)
                throw new ArgumentNullException("InkCanvasAnnotation");

            _InkCanvasAnnotation = InkCanvasAnnotation;

            // Establish a binding between the InkCanvasAnnotation's Text
            // and our Content property so that changes in either
            // property will update the other.
            Binding binding = new Binding("Text");
            binding.Source = _InkCanvasAnnotation;
            binding.Mode = BindingMode.TwoWay;
            this.SetBinding(ContentControl.ContentProperty, binding);

            // Allow this control to be focused,
            // so that we can steal focus from the
            // TextBox used to edit the annotation.
            base.Focusable = true;

            // Prevent the control from having a focus rect.
            base.FocusVisualStyle = null;

            this.IsInEditMode = true;
        }
        public void Initialize()
        {
            if (ECPart != null)
            {
                BindingUtility.SetBindingObject(textBoxServerIP, BindingMode.TwoWay, ECPart, TextBox.TextProperty, "IPAddress");
                BindingUtility.SetBindingObject(textBoxServerPort, BindingMode.TwoWay, ECPart, TextBox.TextProperty, "Port");
                BindingUtility.SetBindingObject(textBoxReceivedData, BindingMode.OneWay, ECPart, TextBox.TextProperty, "ECString");
                //BindingUtility.SetBindingObject(textBoxParsingData, BindingMode.OneWay, ECPart, TextBox.TextProperty, "ParsingReceivedData");

                comboBoxCommandList.ItemsSource = _ecCommandPages.PageList.Keys;
                Binding bd = new Binding("SelectedCommandName");
                bd.Source = _ecCommandPages;
                bd.Mode = BindingMode.TwoWay;
                comboBoxCommandList.SetBinding(ComboBox.TextProperty, bd);

                bd = new Binding("SelectedPage");
                bd.Source = _ecCommandPages;
                bd.Mode = BindingMode.OneWay;
                frameCommand.SetBinding(Frame.ContentProperty, bd);

                bd = new Binding("ExistReceivedData");
                bd.Source = ECPart;
                bd.Mode = BindingMode.OneWay;
                frameCommand.SetBinding(Frame.IsEnabledProperty, bd);

                ECPart.OnReceivedData += OnReceivedData;
            }
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (IsList)
     {
         var control = new ParameterListGrid();
         var binding = new Binding
         {
             Path = new PropertyPath("Items", new object[0]),
             UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
             Source = this
         };
         control.SetBinding(ParameterListGrid.ObjectsProperty, binding);
         WpfHelper.ShowControlInNewDialog(control, "Default object list");
     }
     else
     {
         var control = new ParameterSettingControl
         {
             Parameter = Item
         };
         string name = this.Item != null ? this.Item.Name : "Default name";
         WpfHelper.ShowControlInNewDialog(control, name);
         button.Content = Item.ToString();
     }
 }
Beispiel #27
0
 protected override void UpdateTarget(object target)
 {
     if (!this.Boolean_2)
     {
         if (this.Boolean_1)
         {
             FrameworkElement element = target as FrameworkElement;
             if (element != null)
             {
                 MultiBinding binding = this.method_1();
                 element.SetBinding(base.TargetProperty as DependencyProperty, binding);
             }
         }
         else if (this.Boolean_0)
         {
             FrameworkElement element2 = target as FrameworkElement;
             if (element2 != null)
             {
                 System.Windows.Data.Binding binding2 = this.method_0();
                 element2.SetBinding(base.TargetProperty as DependencyProperty, binding2);
             }
         }
         else
         {
             base.UpdateTarget(target);
         }
     }
 }
        public static void LoadAndMonitor(INotifyPropertyChanged source, string sourceProperty, Control control, DependencyProperty controlProperty = null, IValueConverter converter = null, BindingMode mode = BindingMode.Default)
        {
            var p       = controlProperty ?? GetProperty(control);
            var binding = new System.Windows.Data.Binding(sourceProperty);

            binding.Source    = source;
            binding.IsAsync   = true;
            binding.Converter = converter;
            binding.Mode      = mode;
            if (converter is Converters.PaddSettingToText)
            {
                binding.Mode = BindingMode.OneWay;
                control.SetBinding(p, binding);
            }
            else if (converter != null)
            {
                binding.Mode = BindingMode.OneWayToSource;
                var value = source.GetType().GetProperty(sourceProperty).GetValue(source);
                var v     = converter.Convert(value, null, null, null);
                control.SetBinding(p, binding);
                control.SetValue(p, v);
            }
            else
            {
                control.SetBinding(p, binding);
            }
        }
        public void ApplyBindings(DataGrid parent)
        {
            var gridView = (GridView)PackageGrid.View;
            Debug.Assert(parent.Columns.Count == gridView.Columns.Count);
            for (int i = 0; i < gridView.Columns.Count; i++)
            {
                var binding = new Binding("ActualWidth")
                {
                    Source = parent.Columns[i]
                };

                if (i == 0)
                {
                    // for the Id column, which is the first column, 
                    // it is slightly smaller than the parent column width
                    // due to the left margin.
                    binding.Converter = subtractConverter;
                    binding.ConverterParameter = 3;
                }

                BindingOperations.SetBinding(
                    gridView.Columns[i],
                    GridViewColumn.WidthProperty,
                    binding);
            }
        }
        public override string ToString()
        {
            s = (CUT)base.Tag;

            Binding myBinding = new Binding("result");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = s;
            txtres.SetBinding(TextBox.TextProperty, myBinding);

            Binding myBinding2 = new Binding("variable");
            myBinding2.Mode = BindingMode.TwoWay;
            myBinding2.Source = s;
            txtvar.SetBinding(TextBox.TextProperty, myBinding2);

            Binding myBinding3 = new Binding("delimiter");
            myBinding3.Mode = BindingMode.TwoWay;
            myBinding3.Source = s;
            txtdel.SetBinding(TextBox.TextProperty, myBinding3);

            Binding myBinding4 = new Binding("fieldspec");
            myBinding4.Mode = BindingMode.TwoWay;
            myBinding4.Source = s;
            txtspec.SetBinding(TextBox.TextProperty, myBinding4);


            Binding descbinding = new Binding("Description");
            descbinding.Mode = BindingMode.TwoWay;
            descbinding.Source = s;
            txtdesc.SetBinding(TextBox.TextProperty, descbinding);


            return base.ToString();
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _BackgroundTranslate = GetTemplateChild(PART_BackgroundTranslate) as TranslateTransform;
            _DraggingThumb       = GetTemplateChild(PART_DraggingThumb) as Thumb;
            _SwitchTrack         = GetTemplateChild(PART_SwitchTrack) as Grid;
            _ThumbIndicator      = GetTemplateChild(PART_ThumbIndicator) as FrameworkElement;
            _ThumbTranslate      = GetTemplateChild(PART_ThumbTranslate) as TranslateTransform;

            if (_ThumbIndicator != null && _ThumbTranslate != null && _BackgroundTranslate != null)
            {
                Binding translationBinding;
                translationBinding        = new System.Windows.Data.Binding("X");
                translationBinding.Source = _ThumbTranslate;
                BindingOperations.SetBinding(_BackgroundTranslate, TranslateTransform.XProperty, translationBinding);
            }

            if (_DraggingThumb != null && _ThumbIndicator != null && _ThumbTranslate != null)
            {
                _DraggingThumb.DragStarted   -= _DraggingThumb_DragStarted;
                _DraggingThumb.DragDelta     -= _DraggingThumb_DragDelta;
                _DraggingThumb.DragCompleted -= _DraggingThumb_DragCompleted;
                _DraggingThumb.DragStarted   += _DraggingThumb_DragStarted;
                _DraggingThumb.DragDelta     += _DraggingThumb_DragDelta;
                _DraggingThumb.DragCompleted += _DraggingThumb_DragCompleted;
                if (_SwitchTrack != null)
                {
                    _SwitchTrack.SizeChanged -= _SwitchTrack_SizeChanged;
                    _SwitchTrack.SizeChanged += _SwitchTrack_SizeChanged;
                }
            }
        }
        public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu)
        {
            var buttonHolder = widgetViewModel as DefaultWidgetViewModel;
            var brd = new Border
                          {
                              DataContext = buttonHolder,
                              ContextMenu = contextMenu,
                              BorderBrush = System.Windows.Media.Brushes.Gray,
                              Background = System.Windows.Media.Brushes.White
                          };

            var ret = new Button { DataContext = buttonHolder, ContextMenu = contextMenu, Content = "New Widget" };

            brd.Child = ret;

            var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay };
            var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay };

            brd.SetBinding(InkCanvas.LeftProperty, xBinding);
            brd.SetBinding(InkCanvas.TopProperty, yBinding);
            brd.SetBinding(FrameworkElement.HeightProperty, heightBinding);
            brd.SetBinding(FrameworkElement.WidthProperty, widthBinding);
            brd.SetBinding(UIElement.RenderTransformProperty, transformBinding);

            return brd;
        }
        public DoubleSlider(Core.VplControl hostCanvas)
            : base(hostCanvas)
        {
            AddOutputPortToNode("Number", typeof(double));

            SliderExpanderDouble expander = new SliderExpanderDouble
            {
                Style = hostCanvas.FindResource("ExpanderSliderStyleDouble") as Style,
                SliderValue = 5,
                SliderMax = 10,
                SliderMin = 2,
                SliderStep = 0.01
            };

            var b2 = new Binding("Data")
            {
                Mode = BindingMode.OneWayToSource,
                Source = OutputPorts[0]
            };
            expander.SetBinding(SliderExpanderDouble.SliderValueProperty, b2);

            Name = "Double slider";

            AddControlToNode(expander);
        }
Beispiel #34
0
        public OptionColumnInfo(DataGridColumn column, Type boundObjectType, JibGrid grid)
        {
            if (column == null)
            {
                return;
            }

            Column = column;
            var boundColumn = column as DataGridBoundColumn;

            if (boundColumn != null)
            {
                System.Windows.Data.Binding binding = boundColumn.Binding as System.Windows.Data.Binding;
                if (binding != null && !string.IsNullOrWhiteSpace(binding.Path.Path))
                {
                    System.Reflection.PropertyInfo propInfo = null;
                    //if (boundColumn.Binding != null)
                    //    propInfo = boundColumn.Binding.GetType().GetProperty("Source");
                    if (boundObjectType != null)
                    {
                        propInfo = boundObjectType.GetType().GetProperty(binding.Path.Path);
                    }

                    if (propInfo == null && grid.HasItems)
                    {
                        if (grid.SourceType == null)
                        {
                            grid.SourceType = grid.Items.CurrentItem.GetType();
                        }
                        propInfo = grid.SourceType.GetProperty(binding.Path.Path);
                    }

                    //propInfo = boundObjectType.GetType().GetProperties().FirstOrDefault();
                    //if (propInfo == null) propInfo = boundObjectType.GetProperty("FullName");

                    if (propInfo != null)
                    {
                        IsValid              = true;
                        PropertyPath         = binding.Path.Path;
                        PropertyType         = propInfo != null ? propInfo.PropertyType : typeof(string);
                        Converter            = binding.Converter;
                        ConverterCultureInfo = binding.ConverterCulture;
                        ConverterParameter   = binding.ConverterParameter;
                    }
                    else
                    {
                        if (System.Diagnostics.Debugger.IsAttached && System.Diagnostics.Debugger.IsLogging())
                        {
                            System.Diagnostics.Debug.WriteLine("Jib.WPF.Controls.DataGrid.JibGrid: BindingExpression path error: '{0}' property not found on '{1}'", binding.Path.Path, boundObjectType.ToString());
                        }
                    }
                }
            }
            else if (column.SortMemberPath != null && column.SortMemberPath.Length > 0)
            {
                PropertyPath = column.SortMemberPath;
                PropertyType = boundObjectType.GetProperty(column.SortMemberPath).PropertyType;
            }
        }
Beispiel #35
0
        public void SetupCustomUIElements(dynNodeView nodeUI)
        {
            // Do not call 'NodeModel.InitializeUI' here since it will cause
            // that method to dispatch the call back to 'SetupCustomUIElements'
            // method, resulting in an eventual stack overflow.
            //
            // base.InitializeUI(nodeUI);

            //add a drop down list to the window
            var combo = new ComboBox
            {
                Width               = System.Double.NaN,
                MinWidth            = 100,
                Height              = Configurations.PortHeightInPixels,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center
            };

            nodeUI.inputGrid.Children.Add(combo);
            Grid.SetColumn(combo, 0);
            Grid.SetRow(combo, 0);

            combo.DropDownOpened   += combo_DropDownOpened;
            combo.SelectionChanged += delegate
            {
                if (combo.SelectedIndex != -1)
                {
                    RequiresRecalc = true;
                }
            };

            combo.DropDownClosed += delegate
            {
                //disallow selection of nothing
                if (combo.SelectedIndex == -1)
                {
                    SelectedIndex = 0;
                }
            };

            combo.DataContext = this;
            //bind this combo box to the selected item hash

            var bindingVal = new Binding("Items")
            {
                Mode = BindingMode.TwoWay, Source = this
            };

            combo.SetBinding(ItemsControl.ItemsSourceProperty, bindingVal);

            //bind the selected index to the
            var indexBinding = new Binding("SelectedIndex")
            {
                Mode   = BindingMode.TwoWay,
                Source = this
            };

            combo.SetBinding(Selector.SelectedIndexProperty, indexBinding);
        }
 /// <summary>
 /// 代码实现双向绑定
 /// </summary>
 private void SetBindingForLabel()
 {
     System.Windows.Data.Binding binding = new System.Windows.Data.Binding();
     binding.Source = sliderFontSize;
     binding.Path   = new PropertyPath("Value");
     binding.Mode   = BindingMode.TwoWay;
     label1.SetBinding(Label.FontSizeProperty, binding);
 }
Beispiel #37
0
        log _log        = null; //日志字符串类

        public MainWindow()
        {
            InitializeComponent();
            Receive = new midi();
            Send    = new midi();

            //将arduino发送给pc的数据绑定成绑定源
            Binding binding = new Binding("ReceiveMessage");

            binding.Source = Receive;
            //设置绑定数据修改模式
            binding.Mode = BindingMode.OneWay;
            //将绑定目标设为显示arduino返回数据的textbox
            returnData.SetBinding(TextBox.TextProperty, binding);


            //将pc发送给arduino的数据设为绑定源
            binding        = new Binding("SendMessage");
            binding.Source = Send;
            binding.Mode   = BindingMode.OneWayToSource;
            //将绑定目标设为可写入pc发送命令的textbox
            sendData.SetBinding(TextBox.TextProperty, binding);

            //绑定温度至温度显示textblock中
            binding        = new Binding("getDegree");
            binding.Source = Receive;
            binding.Mode   = BindingMode.OneWay;
            tempre.SetBinding(TextBlock.TextProperty, binding);

            //绑定光强至光强显示textblock中
            binding        = new Binding("getLight");
            binding.Source = Receive;
            binding.Mode   = BindingMode.OneWay;
            light.SetBinding(TextBlock.TextProperty, binding);

            ////绑定led的滑动条至发送数据中
            //setBind(red);
            //setBind(green);
            //setBind(white);
            //setBind(blue);
            //setBind(yellow);

            //设定串口bps
            bps.Items.Clear();
            bps.Items.Add("9600");
            bps.Items.Add("19200");
            bps.Items.Add("38400");
            bps.Items.Add("57600");
            bps.Items.Add("115200");
            bps.Items.Add("921600");
            bps.SelectedItem = bps.Items.GetItemAt(2);

            //初始化zedGraph
            setGraph();

            //初始化log实例
            _log = new log();
        }
Beispiel #38
0
        public override void SetupCustomUIElements(dynNodeView nodeUI)
        {
            //add a button to the inputGrid on the dynElement
            var selectButton = new DynamoNodeButton()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = Configurations.PortHeightInPixels,
            };

            selectButton.Click += selectButton_Click;

            var tb = new TextBox
            {
                HorizontalAlignment    = HorizontalAlignment.Stretch,
                VerticalAlignment      = VerticalAlignment.Center,
                Background             = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)),
                BorderThickness        = new Thickness(0),
                IsReadOnly             = true,
                IsReadOnlyCaretVisible = false,
                MaxWidth     = 200,
                TextWrapping = TextWrapping.Wrap
            };

            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());
            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());

            nodeUI.inputGrid.Children.Add(tb);
            nodeUI.inputGrid.Children.Add(selectButton);

            System.Windows.Controls.Grid.SetRow(selectButton, 0);
            System.Windows.Controls.Grid.SetRow(tb, 1);

            tb.DataContext           = this;
            selectButton.DataContext = this;

            var selectTextBinding = new System.Windows.Data.Binding("SelectionText")
            {
                Mode = BindingMode.TwoWay,
            };

            tb.SetBinding(TextBox.TextProperty, selectTextBinding);

            var buttonTextBinding = new System.Windows.Data.Binding("SelectedElement")
            {
                Mode      = BindingMode.OneWay,
                Converter = new SelectionButtonContentConverter(),
            };

            selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding);

            var buttonEnabledBinding = new System.Windows.Data.Binding("CanSelect")
            {
                Mode = BindingMode.TwoWay,
            };

            selectButton.SetBinding(Button.IsEnabledProperty, buttonEnabledBinding);
        }
Beispiel #39
0
        private void listBoxClasses_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string label = ((Pair)listBoxClasses.SelectedItem).ClassLabel;
            ObservableCollection <string> localImages = ImagesInClass[label];

            System.Windows.Data.Binding b = new System.Windows.Data.Binding();
            b.Source = localImages;
            listBoxImages.SetBinding(ItemsControl.ItemsSourceProperty, b);
        }
Beispiel #40
0
        public static void LoadAndMonitor(INotifyPropertyChanged source, string sourceProperty, Control control, DependencyProperty controlProperty = null)
        {
            var p       = controlProperty ?? GetProperty(control);
            var binding = new System.Windows.Data.Binding(sourceProperty);

            binding.Source  = source;
            binding.IsAsync = true;
            control.SetBinding(p, binding);
        }
Beispiel #41
0
        private void BindDataToEditForm( )
        {
            Binding binding = new Binding( );

            binding.Source = dataItem;
            binding.Mode   = BindingMode.OneWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            EditForm.SetBinding(DataContextProperty, binding);
        }
Beispiel #42
0
        private void inputColor_LostFocus(object sender, RoutedEventArgs e)
        {
            TextBox tb    = (TextBox)e.Source;
            string  s     = tb.Text;
            Binding newbd = new Binding(tb.Tag.ToString());

            newbd.Mode = BindingMode.OneWay;
            tb.SetBinding(TextBox.TextProperty, newbd);
        }
Beispiel #43
0
        public void SetupCustomUIElements(dynNodeView nodeUI)
        {
            this.dynamoViewModel = nodeUI.ViewModel.DynamoViewModel;
            watchTree            = new WatchTree();

            // MAGN-2446: Fixes the maximum width/height of watch node so it won't
            // go too crazy on us. Note that this is only applied to regular watch
            // node so it won't be limiting the size of image/3D watch nodes.
            //
            nodeUI.PresentationGrid.MaxWidth  = Configurations.MaxWatchNodeWidth;
            nodeUI.PresentationGrid.MaxHeight = Configurations.MaxWatchNodeHeight;
            nodeUI.PresentationGrid.Children.Add(watchTree);
            nodeUI.PresentationGrid.Visibility = Visibility.Visible;

            if (Root == null)
            {
                Root = new WatchViewModel(this.dynamoViewModel.VisualizationManager);
            }

            watchTree.DataContext = Root;

            RequestBindingUnhook += delegate
            {
                BindingOperations.ClearAllBindings(watchTree.treeView1);
            };

            RequestBindingRehook += delegate
            {
                var sourceBinding = new Binding("Children")
                {
                    Mode   = BindingMode.TwoWay,
                    Source = Root,
                };
                watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty, sourceBinding);
            };

            var checkedBinding = new Binding("ShowRawData")
            {
                Mode   = BindingMode.TwoWay,
                Source = Root
            };

            var rawDataMenuItem = new MenuItem
            {
                Header      = "Show Raw Data",
                IsCheckable = true,
            };

            rawDataMenuItem.SetBinding(MenuItem.IsCheckedProperty, checkedBinding);

            nodeUI.MainContextMenu.Items.Add(rawDataMenuItem);

            ((PreferenceSettings)this.Workspace.DynamoModel.PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged;

            Root.PropertyChanged += Root_PropertyChanged;
        }
        private IList <IMvxUpdateableBinding> GetOrCreateBindingsList(FrameworkElement attachedObject)
        {
            var existing = attachedObject.GetValue(BindingsListProperty) as IList <IMvxUpdateableBinding>;

            if (existing != null)
            {
                return(existing);
            }

            // attach the list
            var newList = new List <IMvxUpdateableBinding>();

            attachedObject.SetValue(BindingsListProperty, newList);

            // create a binding watcher for the list
#if WINDOWS_PHONE || WINDOWS_WPF
            var binding = new System.Windows.Data.Binding();
#endif
#if NETFX_CORE
            var binding = new Windows.UI.Xaml.Data.Binding();
#endif
            bool   attached     = false;
            Action attachAction = () =>
            {
                if (attached)
                {
                    return;
                }
                BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding);
                attached = true;
            };
            Action detachAction = () =>
            {
                if (!attached)
                {
                    return;
                }
#if WINDOWS_PHONE || NETFX_CORE
                attachedObject.ClearValue(DataContextWatcherProperty);
#else
                BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty);
#endif
                attached = false;
            };
            attachAction();
            attachedObject.Loaded += (o, args) =>
            {
                attachAction();
            };
            attachedObject.Unloaded += (o, args) =>
            {
                detachAction();
            };

            return(newList);
        }
Beispiel #45
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a button to the inputGrid on the dynElement
            _selectButton = new dynNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center
            };
            _selectButton.Click += selectButton_Click;

            _tb = new TextBlock
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)),
                TextWrapping        = TextWrapping.Wrap,
                TextTrimming        = TextTrimming.WordEllipsis,
                MaxWidth            = 200,
                MaxHeight           = 100
            };

            if (SelectedElements == null || !SelectedElements.Any() || !SelectionText.Any() || !SelectButtonContent.Any())
            {
                SelectionText       = "Nothing Selected";
                SelectButtonContent = "Select Instances";
            }


            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());
            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());

            nodeUI.inputGrid.Children.Add(_tb);
            nodeUI.inputGrid.Children.Add(_selectButton);

            System.Windows.Controls.Grid.SetRow(_selectButton, 0);
            System.Windows.Controls.Grid.SetRow(_tb, 1);

            _tb.DataContext           = this;
            _selectButton.DataContext = this;

            var selectTextBinding = new System.Windows.Data.Binding("SelectionText")
            {
                Mode = BindingMode.TwoWay,
            };

            _tb.SetBinding(TextBlock.TextProperty, selectTextBinding);

            var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent")
            {
                Mode = BindingMode.TwoWay,
            };

            _selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding);
        }
        /// <summary>
        /// 绑定昵称
        /// </summary>
        private void BindLongNickName()
        {
            System.Windows.Data.Binding binding = new System.Windows.Data.Binding("LongNickName")
            {
                Source = buddyList.Self,

                Mode = BindingMode.OneWay
            };
            this.longNickName.SetBinding(System.Windows.Controls.TextBox.TextProperty, binding);
        }
Beispiel #47
0
            swd.Binding CreateBinding(string property)
            {
                var binding = new swd.Binding();

                binding.Source = this;
                binding.Path   = new sw.PropertyPath(property);
                binding.Mode   = swd.BindingMode.OneWay;
                binding.UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged;
                return(binding);
            }
        public static void SetBinding(this FrameworkElement target, DependencyProperty targetProperty, DependencyProperty sourceProperty, DependencyObject source, IValueConverter converter = null)
        {
            var binding = new Binding(sourceProperty.Name)
            {
                Mode = BindingMode.OneWay
            };

            binding.Converter = converter;
            target.SetBinding(targetProperty, binding);
        }
Beispiel #49
0
        public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource)
        {
            var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock));
            var binding = new sw.Data.Binding {
                Path = new sw.PropertyPath("Text"), RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.LostFocus
            };

            factory.SetBinding(EditableTextBlock.TextProperty, binding);
            return(factory);
        }
Beispiel #50
0
        private static void SetDataErrorInfoBinding(this DependencyObject element, INotifyDataErrorInfo dataErrorInfo)
        {
            Debug.Assert(dataErrorInfo != null);
            var binding = new System.Windows.Data.Binding(".")
            {
                Source = dataErrorInfo, Mode = BindingMode.TwoWay, ValidatesOnNotifyDataErrors = true
            };

            BindingOperations.SetBinding(element, DummyProperty, binding);
        }
Beispiel #51
0
        public System.Windows.Data.Binding SetBinding(T1 obj, string path, object source)
        {
            var binding = new System.Windows.Data.Binding(path)
            {
                Source = source
            };

            obj.SetBinding(this.ActualDependencyProperty, binding);
            return(binding);
        }
 public Binding CreateValueBinding()
 {
     System.Windows.Data.Binding valueBinding = new System.Windows.Data.Binding();
     valueBinding.Mode = BindingMode.TwoWay;
     valueBinding.NotifyOnValidationError = true;
     valueBinding.ValidatesOnExceptions   = true;
     valueBinding.UpdateSourceTrigger     = UpdateSourceTrigger.Explicit;
     valueBinding.Path = new PropertyPath(this.DataMemberBinding.Path.Path);
     return(valueBinding);
 }
 public FrameworkElement ResolveEditor(Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem)
 {
     System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Value")
     {
         Source = propertyItem,
         Mode   = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay
     };
     BindingOperations.SetBinding(this, FolderNameSelector.ValueProperty, binding);
     return(this);
 }
Beispiel #54
0
        public void CustomizeView(DSDropDownBase model, NodeView nodeView)
        {
            this.model = model;

            //add a drop down list to the window
            var combo = new ComboBox
            {
                Width               = System.Double.NaN,
                MinWidth            = 100,
                Height              = Configurations.PortHeightInPixels,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center
            };

            nodeView.inputGrid.Children.Add(combo);
            System.Windows.Controls.Grid.SetColumn(combo, 0);
            System.Windows.Controls.Grid.SetRow(combo, 0);

            combo.DropDownOpened   += combo_DropDownOpened;
            combo.SelectionChanged += delegate
            {
                if (combo.SelectedIndex != -1)
                {
                    model.OnNodeModified();
                }
            };

            combo.DropDownClosed += delegate
            {
                //disallow selection of nothing
                if (combo.SelectedIndex == -1)
                {
                    model.SelectedIndex = 0;
                }
            };

            combo.DataContext = model;
            //bind this combo box to the selected item hash

            var bindingVal = new System.Windows.Data.Binding("Items")
            {
                Mode = BindingMode.TwoWay, Source = model
            };

            combo.SetBinding(ItemsControl.ItemsSourceProperty, bindingVal);

            //bind the selected index to the
            var indexBinding = new Binding("SelectedIndex")
            {
                Mode   = BindingMode.TwoWay,
                Source = model
            };

            combo.SetBinding(Selector.SelectedIndexProperty, indexBinding);
        }
Beispiel #55
0
        private void bigImageList()
        {
            DataTemplate            DT      = new DataTemplate();
            FrameworkElementFactory fefMain = new FrameworkElementFactory(typeof(UniformGrid));

            fefMain.SetValue(UniformGrid.WidthProperty, 100.0);
            fefMain.SetValue(UniformGrid.RowsProperty, 2);
            fefMain.SetValue(UniformGrid.ColumnsProperty, 1);

            FrameworkElementFactory fefSecondRow = new FrameworkElementFactory(typeof(UniformGrid));

            fefSecondRow.SetValue(UniformGrid.RowsProperty, 1);
            fefSecondRow.SetValue(UniformGrid.ColumnsProperty, 2);

            FrameworkElementFactory fefLabelName = new FrameworkElementFactory(typeof(Label));
            Binding bindLabelName = new Binding();

            bindLabelName.Path = new PropertyPath("name");
            fefLabelName.SetBinding(Label.ContentProperty, bindLabelName);

            fefMain.AppendChild(fefLabelName);
            fefMain.AppendChild(fefSecondRow);

            FrameworkElementFactory fefLabelPrice = new FrameworkElementFactory(typeof(Label));
            Binding bindLabelPrice = new Binding();

            bindLabelPrice.Path = new PropertyPath("price");
            fefLabelPrice.SetValue(Label.ContentProperty, bindLabelPrice);
            fefSecondRow.AppendChild(fefLabelPrice);

            FrameworkElementFactory fefLabelWeight = new FrameworkElementFactory(typeof(Label));
            Binding bindLabelWeight = new Binding();

            bindLabelWeight.Path = new PropertyPath("weight");
            fefLabelWeight.SetBinding(Label.ContentProperty, bindLabelWeight);
            fefSecondRow.AppendChild(fefLabelWeight);

            DT.VisualTree = fefMain;
            this.listView1.ItemTemplate = DT;

            this.listView1.View = null;

            ItemsPanelTemplate      IPT           = new ItemsPanelTemplate();
            FrameworkElementFactory fefItemsPanel = new FrameworkElementFactory(typeof(WrapPanel));

            Binding bindWidth = new System.Windows.Data.Binding("ActualWidth");

            bindWidth.Source = this.listView1;

            fefItemsPanel.SetValue(WrapPanel.WidthProperty, bindWidth);
            fefItemsPanel.SetValue(WrapPanel.OrientationProperty, Orientation.Horizontal);
            IPT.VisualTree            = fefItemsPanel;
            this.listView1.ItemsPanel = IPT;
        }
Beispiel #56
0
        public NewLine()
        {
            Height = 0;
            var binding = new System.Windows.Data.Binding
            {
                RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(WrapPanel), 1),
                Path           = new PropertyPath("ActualHeight")
            };

            BindingOperations.SetBinding(this, WidthProperty, binding);
        }
Beispiel #57
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ViewModel = ((System.Windows.Data.Binding)(target));
                return;

            case 2:
                this.groupBox = ((System.Windows.Controls.GroupBox)(target));
                return;

            case 3:
                this.Ch1Live = ((NationalInstruments.Controls.Graph)(target));
                return;

            case 4:
                this.xScale = ((NationalInstruments.Controls.AxisDouble)(target));
                return;

            case 5:
                this.yScale = ((NationalInstruments.Controls.AxisDouble)(target));
                return;

            case 6:
                this.Ch1Seal = ((NationalInstruments.Controls.Graph)(target));
                return;

            case 7:
                this.xScale1 = ((NationalInstruments.Controls.AxisDouble)(target));
                return;

            case 8:
                this.yScale1 = ((NationalInstruments.Controls.AxisDouble)(target));
                return;

            case 9:
                this.checkBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 10:
                this.toggleButton = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 11:
                this.label = ((System.Windows.Controls.Label)(target));
                return;

            case 12:
                this.label_Copy = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #58
0
        /// <summary>
        /// get appropriate field name binding at specify column index
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        protected System.Windows.Data.Binding getBinding3At(int index)
        {
            System.Windows.Data.Binding binding = new System.Windows.Data.Binding(getBindingName3At(index));
            string stringFormat = getStringFormatAt(index);

            if (!string.IsNullOrEmpty(stringFormat))
            {
                binding.StringFormat = stringFormat;
            }
            return(binding);
        }
Beispiel #59
0
        private void InnerTextBlock_Loaded(object sender, RoutedEventArgs e)
        {
            TextBlock textBlock = (TextBlock)sender;

            System.Windows.Data.Binding bind = new System.Windows.Data.Binding();
            bind.Source = ram;
            bind.Path   = new PropertyPath("Storage[" + (Convert.ToInt32(InputAddressTextBox.Text) / 4) + "]");
            bind.Mode   = BindingMode.OneWay;
            textBlock.SetBinding(TextBlock.TextProperty, bind);
            InputAddressTextBox.Text = "";
        }
Beispiel #60
0
        /// <summary>
        /// The Evaluate
        /// </summary>
        /// <param name="path">The <see cref="PropertyPath" /></param>
        /// <param name="source">The <see cref="object" /></param>
        /// <returns>The <see cref="object" /></returns>
        public static object Evaluate(PropertyPath path, object source)
        {
            var target  = new DependencyTarget();
            var binding = new System.Windows.Data.Binding {
                Path = path, Source = source, Mode = BindingMode.OneTime
            };

            BindingOperations.SetBinding(target, DependencyTarget.ValueProperty, binding);

            return(target.Value);
        }