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


C# ToggleButton.SetBinding方法代码示例

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


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

示例1: BindTheButton

        public BindTheButton()
        {
            Title = "Bind The Button";
            ToggleButton btn = new ToggleButton();
            btn.Content = "Make _Topmost";
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment = VerticalAlignment.Center;
            btn.SetBinding(ToggleButton.IsCheckedProperty, "Topmost");
            btn.DataContext = this;
            Content = btn;

            ToolTip tip = new ToolTip();
            tip.Content = "Toggle the button on to make the window topmost on the desktop";
            btn.ToolTip = tip;
        }
开发者ID:volkoff-pro,项目名称:Petzold.WPF,代码行数:15,代码来源:BindTheButton.cs

示例2: SetDefaultWindowData

        private void SetDefaultWindowData()
        {
            Title = "Bind the Button";

            ToggleButton toggleButton = new ToggleButton();

            toggleButton.Content = "Make _TopMost";
            //toggleButton.HorizontalAlignment = HorizontalAlignment.Center;
            //toggleButton.VerticalAlignment = VerticalAlignment.Center;
            
            // **
            toggleButton.SetBinding(ToggleButton.IsCheckedProperty, "TopMost");
            toggleButton.DataContext = this;

            Content = toggleButton;

            ToolTip tip = new ToolTip();

            // tooltip의 content에 image를 적용 시킬 수 있다.
            tip.Content = "Toggle the button on the make the window top most on the desktop";

            toggleButton.ToolTip = tip;
        }
开发者ID:yoosuphwang,项目名称:DotNet_App,代码行数:23,代码来源:BindingDependencyProperty.xaml.cs

示例3: OnApplyTemplate

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_toggleButton != null)
            {
                _toggleButton.Checked -= CheckedHandler;
                _toggleButton.Unchecked -= UncheckedHandler;
                _toggleButton.Indeterminate -= IndeterminateHandler;
                _toggleButton.Click -= ClickHandler;
                BindingOperations.ClearBinding(_toggleButton, ToggleButton.IsCheckedProperty);

                _toggleButton.IsEnabledChanged -= IsEnabledHandler;

                _toggleButton.PreviewMouseUp -= this.ToggleButtonPreviewMouseUp;
            }
            _toggleButton = GetTemplateChild(SwitchPart) as ToggleButton;
            if (_toggleButton != null)
            {
                _toggleButton.Checked += CheckedHandler;
                _toggleButton.Unchecked += UncheckedHandler;
                _toggleButton.Indeterminate += IndeterminateHandler;
                _toggleButton.Click += ClickHandler;
                var binding = new Binding("IsChecked") { Source = this };
                _toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding);

                _toggleButton.IsEnabledChanged += IsEnabledHandler;

                _toggleButton.PreviewMouseUp += this.ToggleButtonPreviewMouseUp;
            }
            ChangeVisualState(false);
        }
开发者ID:gjhwssg,项目名称:MahApps.Metro,代码行数:32,代码来源:ToggleSwitch.cs

示例4: OnApplyTemplate

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (!_wasContentSet && GetBindingExpression(ContentProperty) == null)
            {
                SetDefaultContent();
            }

            if (_toggleButton != null)
            {
                _toggleButton.Checked -= CheckedHandler;
                _toggleButton.Unchecked -= UncheckedHandler;
                _toggleButton.Indeterminate -= IndeterminateHandler;
                _toggleButton.Click -= ClickHandler;
                BindingOperations.ClearBinding(_toggleButton, ToggleButton.IsCheckedProperty);

                _toggleButton.IsEnabledChanged -= IsEnabledHandler;
            }
            _toggleButton = GetTemplateChild(SwitchPart) as ToggleButton;
            if (_toggleButton != null)
            {
                _toggleButton.Checked += CheckedHandler;
                _toggleButton.Unchecked += UncheckedHandler;
                _toggleButton.Indeterminate += IndeterminateHandler;
                _toggleButton.Click += ClickHandler;
                var binding = new Binding("IsChecked") { Source = this };
                _toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding);

                _toggleButton.IsEnabledChanged += IsEnabledHandler;
            }
            ChangeVisualState(false);
        }
开发者ID:GeertvanHorrik,项目名称:MahApps.Metro,代码行数:33,代码来源:ToggleSwitch.cs

示例5: grid_LoadedRowHeaderPresenter

 private void grid_LoadedRowHeaderPresenter(object sender, C1.WPF.DataGrid.DataGridRowEventArgs e)
 {
     var task = e.Row.DataItem as Task;
     var rowHeaderPresenter = e.Row.HeaderPresenter;
     if (task.SubTasks.Count > 0)
     {
         var toggleButton = new ToggleButton();
         toggleButton.Style = Resources["TButtonStyle"] as Style;
         toggleButton.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsExpanded")
         {
             Source = task,
             Mode = BindingMode.TwoWay
         });
         toggleButton.IsThreeState = false;
         toggleButton.Tag = task;
         rowHeaderPresenter.Content = toggleButton;
     }
     else
     {
         rowHeaderPresenter.Content = null;
     }
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:22,代码来源:HierarchicalTasksPage.xaml.cs

示例6: CreateFavoriteButton

 public ToggleButton CreateFavoriteButton(Status s)
 {
     ToggleButton b = new ToggleButton ();
     Binding fontSizeBinding = CreateBinding (this, FontSizeProperty.Name, BindingMode.OneWay);
     b.SetBinding (ToggleButton.WidthProperty, fontSizeBinding);
     b.SetBinding (ToggleButton.HeightProperty, fontSizeBinding);
     Binding favBinding = CreateBinding (s, "IsFavorited", BindingMode.OneWay);
     b.SetBinding (ToggleButton.IsCheckedProperty, favBinding);
     b.Margin = new Thickness (0, 0, 3, 0);
     b.VerticalAlignment = VerticalAlignment.Center;
     b.Click += isFav_Click;
     b.Style = (Style)Resources["favoriteButton"];
     return b;
 }
开发者ID:atrandom,项目名称:ktwt,代码行数:14,代码来源:TwitterStatusViewer.xaml.cs

示例7: ChildrenAddHandler

        public void ChildrenAddHandler(Object sender, RoutedEventArgs evt)
        {
            FrameworkElement newChild = (FrameworkElement)evt.OriginalSource;
            this.Children.Remove(newChild);
            contentBox.Visibility = Visibility.Visible;
            contentBox.Width = 0;
            //buttonsDockPanel.Width = BUTTON_BAR_WIDTH;
            buttonsDockPanel.Visibility = Visibility.Visible;

            ToggleButton newButton = new ToggleButton();
            if (this.FindResource("ButtonBarTemplate") is ControlTemplate)
                newButton.Template = (ControlTemplate)this.FindResource("ButtonBarTemplate");
            newButton.Height = 30;
            newButton.Margin = new Thickness(0, 0.5, 0, 0.5);
            newButton.Foreground = Brushes.White;
            newButton.FontSize = 14;
            Binding b = new Binding();
            b.Source = newChild;
            b.Path = new PropertyPath(PlayerContentPanel.ButtonsNameProperty);
            newButton.SetBinding(ToggleButton.ContentProperty, b);
            newButton.Click += new RoutedEventHandler(buttons_Click);
            buttonsDockPanel.Children.Add(newButton);
            newButton.VerticalAlignment = VerticalAlignment.Top;
            newButton.HorizontalAlignment = HorizontalAlignment.Stretch;
            DockPanel.SetDock(newButton, Dock.Top);

            this.buttonControlMapping.Add(newButton, newChild);
        }
开发者ID:nexus49,项目名称:grado,代码行数:28,代码来源:PlayerContentPanel.cs


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