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


C# Button.SetBinding方法代码示例

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


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

示例1: CreateButton

 public static Button CreateButton(String text, int height, int width, String horizAlign, String vertAlign)
 {
     Button basicButton = new Button();
     basicButton.Height = height;
     basicButton.Width = width;
     basicButton.Content = text;
     basicButton.SetBinding(Button.HorizontalAlignmentProperty, horizAlign);
     basicButton.SetBinding(Button.VerticalAlignmentProperty, vertAlign);
     return basicButton;
 }
开发者ID:kojakangas,项目名称:QuickBooksWPFDataIntegration,代码行数:10,代码来源:WindowEngine.cs

示例2: GlobalDaysOfWeek

        public GlobalDaysOfWeek()
        {
            _currentDateFormat = DateTimeTools.GetCurrentDateFormat();
            _dayOfWeekSelections = new List<DayOfWeekSelection>();

            var shortestDayNamesInOrder = _currentDateFormat.ShortestDayNamesInOrder();
            int i = 0;
            foreach (var shortestDayName in shortestDayNamesInOrder)
            {
                var selection = new DayOfWeekSelection(_currentDateFormat.DayOfWeek(i++), shortestDayName)
                                                   {
                                                       IsSelected = false
                                                   };
                _dayOfWeekSelections.Add(selection);
            }

            InitializeComponent();

            foreach (var dayOfWeekSelection in _dayOfWeekSelections)
            {
                var dayOfWeekButton = new Button() { DataContext = dayOfWeekSelection, FontSize = 14};
                dayOfWeekButton.SetBinding(ContentControl.ContentProperty, new Binding("ShortestDayName"));
                dayOfWeekButton.SetBinding(Control.ForegroundProperty,
                                           new Binding("IsSelected")
                                               {
                                                   Converter = new SelectedStatusColorConverter(),
                                                   ConverterParameter = Foreground
                                               });
               
                dayOfWeekButton.Click += ((s, e) =>
                                              {
                                                  var dows = (DayOfWeekSelection) ((Button) s).DataContext;
                                                  if (AllowEdit)
                                                  {
                                                      dows.IsSelected = !dows.IsSelected;

                                                      var selectedDaysOfWeekList = SelectedDaysOfWeek.ToList();

                                                      if (dows.IsSelected)
                                                          selectedDaysOfWeekList.Add(dows.DayOfWeek);
                                                      else
                                                          selectedDaysOfWeekList.Remove(dows.DayOfWeek);

                                                      SelectedDaysOfWeek = selectedDaysOfWeekList.ToArray();

                                                      //Update binding
                                                      BindingExpression be =
                                                          this.GetBindingExpression(SelectedDaysOfWeekProperty);
                                                      be.UpdateSource();
                                                  }
                                              });

                this.GlobalDaysOfWeekLayoutRoot.Children.Add(dayOfWeekButton);
            }
        }
开发者ID:FoundOPS,项目名称:server,代码行数:55,代码来源:GlobalDaysOfWeek.xaml.cs

示例3: SetPage

        public SetPage()
        {
            InitializeComponent();

              this.DataContext = m_setGame;

              m_setBoardElement.ProvideGame(m_setGame);

              this.Unloaded += delegate(object sender, RoutedEventArgs e) {
            m_setBoardElement.Dispose();
              };

            #if DEBUG

              Button testButton = new Button();
              testButton.Content = "_Test";
              testButton.Click += test_click;
              testButton.SetBinding(Button.IsEnabledProperty, "CanPlay");

              testButton.Padding = new Thickness(5);
              testButton.Margin = new Thickness(10, 0, 0, 0);

              m_stackPanel.Children.Add(testButton);

            #endif
        }
开发者ID:edealbag,项目名称:bot,代码行数:26,代码来源:SetPage.xaml.cs

示例4: GameDialog

        public GameDialog() {
            DataContext = new ViewModel();
            InitializeComponent();

            ProgressRing.Style = FindResource(ProgressStyles.Next) as Style;

            _cancellationSource = new CancellationTokenSource();
            CancellationToken = _cancellationSource.Token;

            var rhmSettingsButton = new Button {
                Content = "RHM Settings",
                Command = RhmService.Instance.ShowSettingsCommand,
                MinHeight = 21,
                MinWidth = 65,
                Margin = new Thickness(4, 0, 0, 0)
            };

            rhmSettingsButton.SetBinding(VisibilityProperty, new Binding {
                Source = RhmService.Instance,
                Path = new PropertyPath(nameof(RhmService.Active)),
                Converter = new FirstFloor.ModernUI.Windows.Converters.BooleanToVisibilityConverter()
            });

            Buttons = new[] { rhmSettingsButton, CancelButton };
        }
开发者ID:gro-ove,项目名称:actools,代码行数:25,代码来源:GameDialog.xaml.cs

示例5: MainPage

        // Constructor
        public MainPage()
        {
            this.DataContext = this._viewModel;

            InitializeComponent();

            for (int i = 0; i < 7; i++)
            {
                ContentGameGrid.RowDefinitions.Add(new RowDefinition());
                ContentGameGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {

                    var button = new Button();
                    button.Style = (Style)Resources["TextButton"];
                    button.Name = i.ToString() + j.ToString();
                    button.SetBinding(Button.ContentProperty, new Binding("Content") { Source = _viewModel.Items[i, j] });
                    button.DataContext = _viewModel.Items[i, j];

                    ContentGameGrid.Children.Add(button);
                    button.Height = 80;
                    int x = i;
                    int y = j;
                    _viewModel.Items[x, y].PropertyChanged += (sender, e) =>
                    {
                        if (_viewModel.Items[x, y].State == inline.Model.State.Empty && mState == GameState.AboutToMoveTheItem)
                            VisualStateManager.GoToState(button, "ValidDestinationForSelected", true);
                        else
                            VisualStateManager.GoToState(button, _viewModel.Items[x, y].State.ToString(), true);
                    };
                    button.Click += new RoutedEventHandler(button_Click);
                    Grid.SetRow(button, i);
                    Grid.SetColumn(button, j);

                }
            }
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }
开发者ID:javier-alvarez,项目名称:Inline,代码行数:43,代码来源:MainPage.xaml.cs

示例6: AddButtonControls

        private void AddButtonControls(ToolbarInfo info)
        {
            var image = new Image
            {
                Source = new BitmapImage(new Uri(info.Image, UriKind.Relative))
            };

            var button = new Button
            {
                Content = image,
                ToolTip = IoC.Kernel.Get<IResourceHelper>().ReadResource(info.Text)
            };

            var binding = new Binding("DataContext." + info.Command)
            {
                RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(BaseWindow), 1),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            button.SetBinding(Button.CommandProperty, binding);
            Items.Add(button);
        }
开发者ID:nearcoding,项目名称:GAP,代码行数:21,代码来源:ExtendedToolbar.xaml.cs

示例7: UIWithHierarchicalPath

        public UIWithHierarchicalPath()
        {
            var grid = new Grid();
            Content = grid;

            var label = new Label();
            label.SetBinding(Label.ContentProperty, new Binding("Items/Description"));
            grid.Children.Add(label);

            var stack = new StackPanel();
            stack.SetBinding(StackPanel.DataContextProperty, new Binding("Items"));
            grid.Children.Add(stack);

            label = new Label();
            label.SetBinding(Label.ContentProperty, new Binding("/Description"));
            stack.Children.Add(label);

            var button = new Button();
            button.SetBinding(Button.ContentProperty, new Binding("/"));
            button.Template = CreateTemplate();
            stack.Children.Add(button);
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:22,代码来源:UIWithHierarchicalPath.cs

示例8: ComboBox

        public ComboBox ( ) {
			this.Background = Brushes.Red;

			this.Padding = new Thickness ();
			this.Margin = new Thickness ();

			window = new Window(this);
			cmdItem = new Button ();
			lbItems = new ListBox ();

			var itemsBinding = new Binding ();
			itemsBinding.Mode = BindingMode.OneWay;
			itemsBinding.Source = this;
			itemsBinding.Path = new PropertyPath ("Items");

			lbItems.Margin = new Thickness (2);
			lbItems.BorderThickness = new Thickness (0);
			lbItems.ItemContainerStyle = (Style)this.FindResource ("ComboBoxItemStyle");
			lbItems.SetBinding (ListBox.ItemsProperty, itemsBinding);
			lbItems.SelectionChanged += (s,e) => {
				window.DialogResult = this.SelectedItem != null;
				window.Close ();
				this.IsDropDownOpen = false;
			};
				
			window.Content = lbItems;

			var selectedItemBinding = new Binding ("SelectedItem");
			selectedItemBinding.Mode = BindingMode.TwoWay;
			selectedItemBinding.Source = lbItems;

			cmdItem.SetBinding (
				Button.ContentProperty, 
				selectedItemBinding);

			this.SetBinding (
				ListBox.SelectedItemProperty, 
				selectedItemBinding);
        }
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:39,代码来源:ComboBox.cs

示例9: CreateOnOffStopOperationInfo

        private void CreateOnOffStopOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName)
        {
            GeneralOperationInfo obj = new GeneralOperationInfo();
            RowDefinition rd = new RowDefinition();
            rd.Height = new GridLength(150, GridUnitType.Auto);
            rd.MinHeight = 100;
            grid.RowDefinitions.Add(rd);
            SetOperationGridColor(grid, grid.RowDefinitions.Count - 1);

            obj.Name = name;
            obj.On = OnAction;
            obj.Off = OffAction;
            obj.StatusOnName = onName;
            obj.StatusOffName = offName;
            obj.IsOn = IsOn;
            obj.IsOff = IsOff;

            Label labelName = new Label();
            labelName.Height = Double.NaN;
            labelName.Width = Double.NaN;
            labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelName.Margin = new Thickness(2);
            Binding bd = new Binding("Name");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            TextBlock textBlockName = new TextBlock();
            textBlockName.TextWrapping = TextWrapping.Wrap;
            textBlockName.TextAlignment = TextAlignment.Center;
            textBlockName.SetBinding(TextBlock.TextProperty, bd);
            labelName.Content = textBlockName;

            Label labelStatus = new Label();
            labelStatus.Height = Double.NaN;
            labelStatus.Width = Double.NaN;
            labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelStatus.Margin = new Thickness(2);
            bd = new Binding("Status");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            TextBlock textBlockStatus = new TextBlock();
            textBlockStatus.TextWrapping = TextWrapping.Wrap;
            textBlockStatus.TextAlignment = TextAlignment.Center;
            textBlockStatus.SetBinding(TextBlock.TextProperty, bd);
            labelStatus.Content = textBlockStatus;

            Grid gridInputIOList = CreatePartInputIOList(part);
            Grid gridOutputIOList = CreatePartOutputIOList(part);

            Button buttonOnOff = new Button();
            buttonOnOff.Height = Double.NaN;
            buttonOnOff.Width = Double.NaN;
            buttonOnOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            buttonOnOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            buttonOnOff.Margin = new Thickness(2);
            bd = new Binding("ButtonCaption");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            buttonOnOff.SetBinding(Button.ContentProperty, bd);
            buttonOnOff.Click +=
                delegate(object sender, RoutedEventArgs e)
                {
                    if (obj.IsOn())
                        OffAction(sender);
                    else
                    {
                        if (obj.IsOff())
                            OnAction(sender);
                        else if (StopAction != null)
                        {
                            StopAction(sender);
                        }
                        else
                            OnAction(sender);
                    }
                };

            TextBox textBoxRepeat = new TextBox();
            textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            textBoxRepeat.Height = Double.NaN;
            textBoxRepeat.Width = Double.NaN;
            textBoxRepeat.Margin = new Thickness(2);
            bd = new Binding("RepeatTime");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            FAFramework.Utility.BindingUtility.SetBindingObject(textBoxRepeat, BindingMode.TwoWay, obj, TextBox.TextProperty, "RepeatTime");

            CheckBox checkBoxRepeatUse = new CheckBox();
            checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            checkBoxRepeatUse.LayoutTransform = new ScaleTransform(CHECKBOX_SIZE, CHECKBOX_SIZE);
            bd = new Binding("RepeatUse");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd);

            int rowCount = grid.RowDefinitions.Count - 1;
            grid.Children.Add(labelName);
//.........这里部分代码省略.........
开发者ID:vesteksoftware,项目名称:VT8642,代码行数:101,代码来源:PageManual.xaml.cs

示例10: DisplayXML

        internal static void DisplayXML(ListBox ListBox1, ObjectXML table)
        {
            ListBox1.Items.Clear();

            StackPanel panel1 = new StackPanel();
            panel1.Orientation = Orientation.Horizontal;
            ListBox1.VerticalAlignment = VerticalAlignment.Center;
            ListBox1.HorizontalAlignment = HorizontalAlignment.Center;

            for (int col = 0; col < table.colNum; col++)
            {
                Button button = new Button();
                Coords coords = new Coords(0, col);

                button.Name = "field" + '_' + (col + 1).ToString() + '_' + 0.ToString();
                button.DataContext = MainWindow.objectXML.header[coords.GetHashCode()];
                button.SetBinding(Button.ContentProperty, new Binding("headerCellHeader"));
                button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
                button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
                button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));

                button.Click += EditHeaderClick;
                button.Foreground = Brushes.Black;

                AlignChange(ref button, coords);
                getRes(button);

                button.Padding = new Thickness(5, 0, 5, 0);
                button.Background = Brushes.LightGray;
                button.BorderBrush = Brushes.Black;

                if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;

                panel1.Children.Add(button);
            }

            ListBox1.Items.Add(panel1);

            for (int row = 1; row < table.rowNum; row++)
            {

                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                for (int col = 0; col < table.colNum; col++)
                {
                    Button button = new Button();
                    Coords coords = new Coords(row, col);
                    Binding bindParam = new Binding();
                    bindParam.Source = MainWindow.objectXML.cells[coords.GetHashCode()];
                    bindParam.Path = new PropertyPath("tabCellParametr");
                    button.Name = "field" + '_' + (col + 1).ToString() + '_' + row.ToString();
                    button.SetBinding(Button.ContentProperty,bindParam);
                    button.DataContext = MainWindow.objectXML.header[new Coords(0, col).GetHashCode()];
                    button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
                    button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
                    button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));
                    button.Foreground = Brushes.Black;
                    button.Padding = new Thickness(5, 0, 5, 0);
                    button.Click += EditCellClick;
                    getRes(button);
                    AlignChange(ref button, coords);

                    button.Background = Brushes.LightGray;
                    button.BorderBrush = Brushes.Black;

                    if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;

                    panel.Children.Add(button);
                }

                ListBox1.Items.Add(panel);
            }
        }
开发者ID:KirillChernoff,项目名称:Studio,代码行数:73,代码来源:Logic.cs

示例11: LoadTiles

        private void LoadTiles()
        {
            // TODO: This method could probably be be optimized! We can probably get away without reloading everything every time.

            lock (this)
            {
                foreach (var child in Children)
                {
                    var childButton = child as Button;
                    if (childButton != null)
                    {
                        childButton.Content = null;
                        childButton.DataContext = null;
                    }
                }
                Children.Clear();

                var actionsHost = DataContext as IHaveActions;
                if (actionsHost != null)
                {
                    List<IViewAction> currentActions;
                    lock (actionsHost.Actions) // Trying to do this as quickly as possible to avoid threading problems
                        currentActions = actionsHost.Actions.OrderBy(a => a.CategoryOrder).ToList();

                    RemoveAllMenuKeyBindings();

                    foreach (var action in currentActions)
                    {
                        var button = new Button();
                        button.SetResourceReference(StyleProperty, "Metro-Control-TileButton");
                        button.Command = action;

                        var visibilityBinding = new Binding("Availability") {Source = action, Converter = new AvailabilityToVisibilityConverter()};
                        button.SetBinding(VisibilityProperty, visibilityBinding);

                        if (action.ActionView == null)
                        {
                            var realAction = action as ViewAction;
                            if (realAction != null && !realAction.HasBrush && !realAction.HasExecuteDelegate && string.IsNullOrEmpty(action.Caption))
                                continue; // Not adding this since is has no brush and no execute and no caption

                            switch (action.Significance)
                            {
                                case ViewActionSignificance.Highest:
                                    var view = Controller.LoadView("CODEFrameworkStandardViewTileWideSquare");
                                    button.Content = view;
                                    view.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.DoubleSquare);
                                    break;
                                case ViewActionSignificance.AboveNormal:
                                    var view2 = Controller.LoadView("CODEFrameworkStandardViewTileWide");
                                    button.Content = view2;
                                    view2.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view2; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.Double);
                                    break;
                                case ViewActionSignificance.Normal:
                                case ViewActionSignificance.BelowNormal:
                                    var view3 = Controller.LoadView("CODEFrameworkStandardViewTileNarrow");
                                    button.Content = view3;
                                    view3.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view3; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.Normal);
                                    break;
                                case ViewActionSignificance.Lowest:
                                    var view4 = Controller.LoadView("CODEFrameworkStandardViewTileTiny");
                                    button.Content = view4;
                                    view4.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view4; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.Tiny);
                                    break;
                            }
                        }
                        else
                        {
                            button.Content = action.ActionView;
                            if (action.ActionView.DataContext == null) action.ActionView.DataContext = action.ActionViewModel ?? action;
                            switch (action.Significance)
                            {
                                case ViewActionSignificance.Highest:
                                    SetTileWidthMode(button, TileWidthModes.DoubleSquare);
                                    break;
                                case ViewActionSignificance.AboveNormal:
                                    SetTileWidthMode(button, TileWidthModes.Double);
                                    break;
                                case ViewActionSignificance.Normal:
                                case ViewActionSignificance.BelowNormal:
                                    SetTileWidthMode(button, TileWidthModes.Normal);
                                    break;
                                case ViewActionSignificance.Lowest:
                                    SetTileWidthMode(button, TileWidthModes.Tiny);
                                    break;
                            }
                        }

                        if (action.Categories.Count > 0)
                        {
                            SetGroupName(button, action.Categories[0].Id);
                            SetGroupTitle(button, action.Categories[0].Caption);
//.........这里部分代码省略.........
开发者ID:sat1582,项目名称:CODEFramework,代码行数:101,代码来源:ShellMetroTiles.cs

示例12: CreateLabelElement

 /// <summary>
 /// Creates the element for a label.
 /// </summary>
 /// <param name="text">The text that is set as content.</param>
 /// <param name="timespan">The TimeSpan that is represented by the Button.</param>
 /// <returns>A Button representing the label.</returns>
 private Button CreateLabelElement(string text, TimeSpan timespan)
 {
     Button c = new Button();
     c.SetBinding(
         StyleProperty, 
         new Binding()
                                     {
                                             Path = new PropertyPath("TimeButtonStyle"),
                                             Source = this
                                     });
     c.VerticalAlignment = VerticalAlignment.Top;
     // the easiest way to pass a value. Since we manage this element
     // there is no interference possible.
     c.Tag = timespan;
     c.Content = text;
     c.Click += OnLabelClicked;
     return c;
 }
开发者ID:modulexcite,项目名称:SilverlightToolkit,代码行数:24,代码来源:RangeTimePickerPopup.cs

示例13: SetupCustomUIElements

        public override void SetupCustomUIElements(Controls.dynNodeView nodeUI)
        {
            //add a button to the inputGrid on the dynElement
            _selectButton = new dynNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center
            };
            _selectButton.Click += selectButton_Click;

            _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
            };

            //tb.Text = "Nothing Selected";
            if (SelectedElement == null || !SelectionText.Any() || !SelectButtonContent.Any())
            {
                SelectionText = "Nothing Selected";
                SelectButtonContent = "Select Instance";
            }

            //NodeUI.SetRowAmount(2);
            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("SelectButtonContent")
            {
                Mode = BindingMode.TwoWay,
            };
            _selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding);
        }
开发者ID:epeter61,项目名称:Dynamo,代码行数:52,代码来源:dynSelection.cs

示例14: OnApplyTemplate

        /// <summary>
        /// Called when [apply template].
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate ();
            _btnSave = GetTemplateChild ( "Part_SaveButton" ) as Button;
            _btnNext = GetTemplateChild ( "Part_NextButton" ) as Button;
            _btnCancel = GetTemplateChild ( "Part_CancelButton" ) as Button;
            _focusElement = GetTemplateChild ( "Part_Focus" ) as Grid;
            _contentPresenter = GetTemplateChild ( "PART_ContentPresenter" ) as ContentPresenter;
            _maximizeGrid = GetTemplateChild ( "PART_MaximizeGrid" ) as Grid;
            _rootGrid = GetTemplateChild ( "PART_RootGrid" ) as Grid;

            _saveCompositeCommand = new CompositeCommand ();
            _saveCompositeCommand.RegisterCommand ( new DelegateCommand ( ExecuteSaveCommand ) );
            if ( SaveCommand != null )
            {
                _saveCompositeCommand.RegisterCommand ( SaveCommand );
                if ( !_afterSaveCommandIntialized )
                {
                    _afterSaveCommandIntialized = true;
                    _saveCompositeCommand.RegisterCommand ( new DelegateCommand ( AfterSaveCommandExecute ) );
                }
            }
            _btnSave.Command = _saveCompositeCommand;
            var contentBinding = new Binding ();
            contentBinding.Source = this;
            contentBinding.Path = new PropertyPath ( PropertyUtil.ExtractPropertyName ( () => Content ) );
            _btnSave.SetBinding ( ButtonBase.CommandParameterProperty, contentBinding );
            _btnNext.Click += NextClicked;
            _btnCancel.Click += CancelClick;
            LostFocus += Content_LostFocus;
            _focusElement.MouseLeftButtonDown += Content_MouseLeftButtonDown;
            AddHandler ( MouseLeftButtonDownEvent, new MouseButtonEventHandler ( EditableExpander_MouseLeftButtonDown ), true );
            MouseLeftButtonDown += EditableExpander_MouseLeftButtonDown;

            if ( IsExpanded )
            {
                VisualStateManager.GoToState ( this, "RevealState", true );
            }

            if ( UsingEditableContentTemplate () )
            {
                ContentTemplate = EditableContentTemplate;
            }

            _templateApplied = true;

            UpdateContentPresenter();

            if ( IsEditing )
            {
                TurnOnEditing ();
            }
            else
            {
                TurnOffEditing ();
            }
        }
开发者ID:divyang4481,项目名称:REM,代码行数:60,代码来源:EditableExpander.cs

示例15: AddButton

		private void AddButton(
			string buttonText,
			Action callback,
			bool isDefault,
			bool isCancel,
			string bindingPath)
		{
			var btn = new Button
			{
				Content = buttonText,
				MinWidth = 80,
				MaxWidth = 150,
				IsDefault = isDefault,
				IsCancel = isCancel,
				Margin = new Thickness(5)
			};

			var enabledBinding = new Binding(bindingPath) { Source = _dialog };
			btn.SetBinding(IsEnabledProperty, enabledBinding);

			btn.Click += (s, e) => callback();

			ButtonsGrid.Columns++;
			ButtonsGrid.Children.Add(btn);
		}
开发者ID:tsbrzesny,项目名称:rma-alzheimer,代码行数:25,代码来源:DialogBaseControl.xaml.cs


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