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


C# Control.SetBinding方法代码示例

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


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

示例1: BindProperty

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

示例2: SetBackgroundBinding

 /// <summary>
 /// Sets the background binding.
 /// </summary>
 /// <param name="d">The cell definition.</param>
 /// <param name="c">The control.</param>
 protected virtual void SetBackgroundBinding(CellDefinition d, Control c)
 {
     if (d.BackgroundBindingPath != null)
     {
         var binding = new Binding(d.BackgroundBindingPath) { Source = d.BackgroundBindingSource };
         c.SetBinding(Control.BackgroundProperty, binding);
     }
 }
开发者ID:Mitch-Connor,项目名称:PropertyTools,代码行数:13,代码来源:DataGridControlFactory.cs

示例3: Bind

 public static void Bind(Control control, Action<Control> dataContextChanged)
 {
     control.SetBinding(InternalDataContextProperty, new Binding());
     control.SetValue(DataContextChangedProperty, dataContextChanged);
 }
开发者ID:JohnDMathis,项目名称:Pippin,代码行数:5,代码来源:DataContextChangedHandler.cs

示例4: Attach

        public void Attach(MetaAction metaAction, Control control)
        {
            ValidateType(control);

            var existingItems = controlAction.Where(it => it.Item1 == metaAction);
            var targetItem = existingItems.FirstOrDefault(it =>
            {
                Control c;
                if (it.Item2.TryGetTarget(out c))
                {
                    return c.Equals(control);
                }
                return false;
            });

            // already attached
            if (targetItem != null)
                return;
            Image image = null;
            if (metaAction.Icon != null)
            {
                image = ImageHelper.CreateImage(metaAction);
                image.MaxWidth = MetaAction.ToolBarIconSize;
                image.MaxHeight = MetaAction.ToolBarIconSize;
            }

            if (control is MenuItem)
            {
                var menu = (MenuItem)control;
                menu.Icon = image;
                menu.InputGestureText = metaAction.ShortCut;
                menu.Header = metaAction.Title;
                menu.ToolTip = metaAction.ToolTip;
            }
            if (control is ButtonBase)
            {
                var button = (ButtonBase)control;
                button.Content = image;
                button.ToolTip = metaAction.ToolTip;
                if (!string.IsNullOrEmpty(metaAction.ShortCut))
                {
                    button.ToolTip += ": " + metaAction.ShortCut;
                }
            }

            control.SetValue(ToolTipService.ShowOnDisabledProperty, true);
            // IsEnabled property

            // Visibility
            control.SetBinding(UIElement.VisibilityProperty,
                new Binding
                {
                    Source = metaAction,
                    Path = new PropertyPath("IsVisible"),
                    Mode = BindingMode.OneWay,
                    Converter = BooleanToVisibilityConverter.Instance,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                });

            // Shortcut
            if (metaAction.KeyBinding != null)
            {
                var window = GetWindow(control);
                if (!window.InputBindings.Contains(metaAction.KeyBinding))
                {
                    window.InputBindings.Add(metaAction.KeyBinding);
                }
            }
              //  Message.SetAttach(control, metaAction.CaliburnAction);
            control.SetValue(Message.AttachProperty, metaAction.CaliburnAction);
            controlAction.Add(new Tuple<MetaAction, WeakReference<Control>>(metaAction, new WeakReference<Control>(control)));
        }
开发者ID:mikel785,项目名称:MetaActionFramework,代码行数:72,代码来源:MetaActionManager.cs


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