当前位置: 首页>>代码示例>>C#>>正文


C# FrameworkElement.SetBinding方法代码示例

本文整理汇总了C#中System.Windows.FrameworkElement.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.SetBinding方法的具体用法?C# FrameworkElement.SetBinding怎么用?C# FrameworkElement.SetBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.FrameworkElement的用法示例。


在下文中一共展示了FrameworkElement.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetBindingObject

        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);
        }
开发者ID:vesteksoftware,项目名称:VT8642,代码行数:34,代码来源:BindingUtility.cs

示例2: SetBindings

        public override void SetBindings(DesignItem item, FrameworkElement view)
        {
            base.SetBindings(item, view);

            view.SetBinding(FrameworkElement.VerticalAlignmentProperty, new Binding("Component.VerticalOptions") { Source = item, Converter = LayoutOptionsToVerticalAlignmentConverter.Instance });
            view.SetBinding(FrameworkElement.HorizontalAlignmentProperty, new Binding("Component.HorizontalOptions") { Source = item, Converter = LayoutOptionsToHorizontalAlignmentConverter.Instance });
        }
开发者ID:jogibear9988,项目名称:XamarinFormsXamlEditor,代码行数:7,代码来源:ViewExtension.cs

示例3: EditableFrameworkElement

        internal EditableFrameworkElement(CanvasEditor editor, FrameworkElement element)
        {
            Editor = editor;
            UIElement = element;
            Position = new PointNotifyPropertyChanged(new Point(
                (double)element.GetValue(Canvas.LeftProperty),
                (double)element.GetValue(Canvas.TopProperty)));
            Size = new SizeNotifyPropertyChanged(new Size(
                (double)element.GetValue(Canvas.WidthProperty),
                (double)element.GetValue(Canvas.HeightProperty)));

            Binding xBinding = new Binding(PointNotifyPropertyChanged.XProperty);
            xBinding.Source = Position;
            element.SetBinding(Canvas.LeftProperty, xBinding);

            Binding yBinding = new Binding(PointNotifyPropertyChanged.YProperty);
            yBinding.Source = Position;
            element.SetBinding(Canvas.TopProperty, yBinding);

            Binding wBinding = new Binding(SizeNotifyPropertyChanged.WidthProperty);
            wBinding.Source = Size;
            element.SetBinding(Canvas.WidthProperty, wBinding);

            Binding hBinding = new Binding(SizeNotifyPropertyChanged.HeightProperty);
            hBinding.Source = Size;
            element.SetBinding(Canvas.HeightProperty, hBinding);

            Position.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Position_PropertyChanged);
            Size.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Size_PropertyChanged);
        }
开发者ID:Kaftan777ski,项目名称:mapinect,代码行数:30,代码来源:EditableFrameworkElement.cs

示例4: SetBindings

        public override void SetBindings(DesignItem item, FrameworkElement view)
        {
            base.SetBindings(item, view);

            view.SetBinding(EntryView.TextProperty, new Binding("Component.Text") { Source = item });
            view.SetBinding(EntryView.VisibilityProperty, new Binding("Component.IsVisible") { Source = item, Converter = IsVisibleToVisibilityConverter.Instance });
            view.SetBinding(EntryView.FontSizeProperty, new Binding("Component.FontSize") { Source = item });
            view.SetBinding(EntryView.ForegroundProperty, new Binding("Component.TextColor") { Source = item, Converter = ColorToBrushConverter.Instance });
        }
开发者ID:jogibear9988,项目名称:XamarinFormsXamlEditor,代码行数:9,代码来源:EntryView.cs

示例5: SetCommonBindings

		protected override void SetCommonBindings(FrameworkElement marker)
		{
			base.SetCommonBindings(marker);

			marker.SetValue(ViewportPanel.YProperty, 0.0);
			marker.SetBinding(ViewportPanel.ViewportHeightProperty, DependentValueBinding);
			marker.SetBinding(ViewportPanel.ViewportWidthProperty, ColumnWidthBinding);
			marker.SetValue(ViewportPanel.ViewportVerticalAlignmentProperty, VerticalAlignment.Bottom);
			marker.SetBinding(ViewportPanel.XProperty, IndexBinding);
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:10,代码来源:ColumnChart.cs

示例6: AddCommonBindings

		protected override void AddCommonBindings(FrameworkElement marker)
		{
			base.AddCommonBindings(marker);

			marker.SetValue(ViewportPanel.XProperty, 0.0);
			marker.SetBinding(ViewportPanel.ViewportWidthProperty, viewportWidthBinding);
			marker.SetValue(ViewportPanel.ViewportHeightProperty, 0.85);
			marker.SetValue(ViewportPanel.ViewportHorizontalAlignmentProperty, HorizontalAlignment.Left);
			marker.SetBinding(ViewportPanel.YProperty, viewportYBinding);
		}
开发者ID:modulexcite,项目名称:DynamicDataDisplay,代码行数:10,代码来源:HorizontalColumnChart.cs

示例7: SetBindingObject

 public static void SetBindingObject(FrameworkElement obj, BindingMode mode, object source, DependencyProperty dp, string propertyName)
 {
     Binding bd = new Binding(propertyName);
     bd.Source = source;
     bd.Mode = mode;
     obj.SetBinding(dp, bd);
 }
开发者ID:vesteksoftware,项目名称:Onyang_CL_CSharp_VT5081,代码行数:7,代码来源:BindingUtility.cs

示例8: ReplaceContent

        /// <summary>
        /// Replaces the content for a <see cref="DataField"/> with another control and updates the bindings.
        /// </summary>
        /// <param name="field">The <see cref="DataField"/> whose <see cref="TextBox"/> will be replaced.</param>
        /// <param name="newControl">The new control you're going to set as <see cref="DataField.Content" />.</param>
        /// <param name="dataBindingProperty">The control's property that will be used for data binding.</param>        
        /// <param name="bindingSetupFunction">
        ///  An optional <see cref="Action"/> you can use to change parameters on the newly generated binding before
        ///  it is applied to <paramref name="newControl"/>
        /// </param>
        /// <param name="sourceProperty">The source dependency property to use for the binding.</param>
        public static void ReplaceContent(this DataField field, FrameworkElement newControl, DependencyProperty dataBindingProperty, Action<Binding> bindingSetupFunction, DependencyProperty sourceProperty)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }

            if (newControl == null)
            {
                throw new ArgumentNullException("newControl");
            }

            // Construct new binding by copying existing one, and sending it to bindingSetupFunction
            // for any changes the caller wants to perform
            Binding newBinding = field.Content.GetBindingExpression(sourceProperty).ParentBinding.CreateCopy();

            if (bindingSetupFunction != null)
            {
                bindingSetupFunction(newBinding);
            }

            // Replace field
            newControl.SetBinding(dataBindingProperty, newBinding);
            field.Content = newControl;
        }
开发者ID:jeffhandley,项目名称:RIAServicesValidation,代码行数:36,代码来源:DataFieldExtensions.cs

示例9: BindProperty

 public static void BindProperty(FrameworkElement element, object source, 
     string path, DependencyProperty property, BindingMode mode)
 {
     var binding = new Binding(path);
     binding.Source = source;
     binding.Mode = mode;
     element.SetBinding(property, binding);
 }
开发者ID:kondoumh,项目名称:iedit-silverlight,代码行数:8,代码来源:BindingFuntions.cs

示例10: Bind

 public static void Bind(object dataSource, string sourcePath, FrameworkElement destinationObject, DependencyProperty dp)
 {
     Binding binding = new Binding();
     binding.Source = dataSource;
     binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
     binding.Path = new PropertyPath(sourcePath);
     destinationObject.SetBinding(dp, binding);
 }
开发者ID:Maloyinvestments,项目名称:sk-jukebox-prototype,代码行数:8,代码来源:UIHelper.cs

示例11: RegisterForNotification

 public static void RegisterForNotification(string property, FrameworkElement frameworkElement, PropertyChangedCallback OnCallBack)
 {
     Binding binding2 = new Binding(property);
     binding2.set_Source(frameworkElement);
     Binding binding = binding2;
     DependencyProperty property2 = DependencyProperty.RegisterAttached("ListenAttached" + property, typeof(object), typeof(UserControl), new PropertyMetadata(OnCallBack));
     frameworkElement.SetBinding(property2, binding);
 }
开发者ID:belsoft,项目名称:traingraph,代码行数:8,代码来源:Helper.cs

示例12: AmplitudeModulate

 public static Oscillator AmplitudeModulate(this Oscillator oscillator, FrameworkElement target, DependencyProperty property)
 {
     Binding frequencyBinding = new Binding();
     frequencyBinding.Mode = BindingMode.TwoWay;
     frequencyBinding.Source = oscillator.AmplitudeModulator;
     frequencyBinding.Path = new PropertyPath("ModulationFrequency");
     target.SetBinding(property, frequencyBinding);
     return oscillator;
 }
开发者ID:cmcginn,项目名称:MHFinance,代码行数:9,代码来源:FluentAudio.cs

示例13: AddCommonBindings

		protected override void AddCommonBindings(FrameworkElement marker)
		{
			base.AddCommonBindings(marker);

			marker.SetValue(ViewportPanel.YProperty, 0.0);

			if (!String.IsNullOrEmpty(DependentValuePath))
			{
				viewportHeightBinding = new Binding(DependentValuePath);
			}

			marker.SetBinding(ViewportPanel.ViewportHeightProperty, viewportHeightBinding);

			if (ViewportPanel.GetViewportWidth(marker).IsNaN())
				marker.SetValue(ViewportPanel.ViewportWidthProperty, 0.85);
			marker.SetValue(ViewportPanel.ViewportVerticalAlignmentProperty, VerticalAlignment.Bottom);
			marker.SetBinding(ViewportPanel.XProperty, viewportXBinding);
		}
开发者ID:modulexcite,项目名称:DynamicDataDisplay,代码行数:18,代码来源:ColumnChart.cs

示例14: Attenuate

 public static Attenuator Attenuate(this Mixer mixer, FrameworkElement target, DependencyProperty property)
 {
     Attenuator attenuator = new Attenuator() { Input = mixer };
     Binding binding = new Binding();
     binding.Mode = BindingMode.TwoWay;
     binding.Source = attenuator;
     binding.Path = new PropertyPath("Attenuation");
     target.SetBinding(property, binding);
     return attenuator;
 }
开发者ID:cmcginn,项目名称:MHFinance,代码行数:10,代码来源:FluentAudio.cs

示例15: BindProperty

        public static void BindProperty(FrameworkElement element, BindableProperty property)
        {
            Guard.ArgumentNotNull(element, "element");

            var enabledBinding = new Binding("ReadOnly");
            enabledBinding.Converter = new BooleanInverseConverter();
            enabledBinding.Source = property;
            element.SetBinding(UIElement.IsEnabledProperty, enabledBinding);

        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:10,代码来源:CustomEditorBinder.cs


注:本文中的System.Windows.FrameworkElement.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。