當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。