• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.Button类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Button类属于System.Windows.Controls命名空间,在下文中一共展示了Button类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MainTab

 public MainTab(int page, TabItem newTab, Image newVerso, Image newRecto, Grid canvas, Grid vGrid, Grid rGrid, Button delBtn, ScatterView SV, ScatterViewItem si, Grid vSwipeGrid, Grid rSwipeGrid, Grid vTranslationGrid, Grid rTranslationGrid, Grid vBoxesGrid, Grid rBoxesGrid, TextBlock headerText, SurfaceWindow1.language language)
 {
     _page = page;
     _tab = newTab;
     _verso = newVerso;
     _recto = newRecto;
     _canvas = canvas;
     _vGrid = vGrid;
     _rGrid = rGrid;
     _SVI = si;
     _delButton = delBtn;
     numFingersRecto = 0;
     numFingersVerso = 0;
     fingerPos = new List<Point>();
     avgTouchPoint = new Point(-1, 0);
     _vSwipeGrid = vSwipeGrid;
     _rSwipeGrid = rSwipeGrid;
     _vTranslationGrid = vTranslationGrid;
     _rTranslationGrid = rTranslationGrid;
     _vBoxesGrid = vBoxesGrid;
     _rBoxesGrid = rBoxesGrid;
     _twoPage = true;
     _SV = SV;
     _headerTB = headerText;
     _currentLanguage = language;
     _previousLanguage = _currentLanguage;
     _worker = new Workers(this);
 }
开发者ID:straboulsi,项目名称:fauvel,代码行数:28,代码来源:Tab.cs


示例2: RepoteUnhandleException

 private void RepoteUnhandleException(Exception ex)
 {
     Button b= new Button() ;
     Window w = new Window {Width = 0x258,Height = 0x1f4,Padding = new Thickness(0x14),Title = String.Format("{0} - {1}","予期せぬエラー","TwVideoUp")};
     StackPanel m = new StackPanel()
     {
         Orientation = Orientation.Vertical,
         Children =
         {
             new TextBlock()
             {
                 Text = "予期せぬエラーが発生しました。以下のStackTraceをIssueとして提出いただけると嬉しいです。(ユーザー名などが含まれている場合は伏せていただいて構いません。)",
                 TextWrapping = TextWrapping.Wrap
             },
             new TextBox()
             {
                 Text = ex.ToString(),
                 IsReadOnly = true,
                 TextWrapping = TextWrapping.Wrap,
                 Margin = new Thickness(10),
                 MaxHeight = 380,
                 VerticalScrollBarVisibility = ScrollBarVisibility.Auto
             },
             b
         },
     };
     b.Click += (sender, args) => Clipboard.SetText(ex.ToString());
     b.Content = new TextBlock() {Text = "Copy to Clipboard."};
     w.Content = m;
     w.ShowDialog();
     Shutdown();
 }
开发者ID:hinaloe,项目名称:TwitterVideoUploader,代码行数:32,代码来源:App.xaml.cs


示例3: Cabecera

        public Cabecera()
        {
            Background = new SolidColorBrush(Colors.White);
            Orientation = Orientation.Vertical;

            var nombreJuego = new TextBlock { Text = "Tres en Línea", FontSize = 78, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center};
            Children.Add(nombreJuego);

            var nuevoJuego = new Button {Content = "Iniciar nuevo Juego", Background = new SolidColorBrush(Colors.Black)};
            nuevoJuego.Tap += nuevoJuego_Tap;
            Children.Add(nuevoJuego);

            Grid resultadoGrid = new Grid{Background = new SolidColorBrush(Colors.White), ShowGridLines = false};

            resultadoGrid.ColumnDefinitions.Add(new ColumnDefinition());
            resultadoGrid.ColumnDefinitions.Add(new ColumnDefinition{Width = new GridLength(2, GridUnitType.Star)});
            resultadoGrid.RowDefinitions.Add(new RowDefinition());

            var labelResultado = new TextBlock { Text = "Resultado:", FontSize = 22, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
            resultadoGrid.Children.Add(labelResultado);
            Grid.SetColumn(labelResultado, 0);

            resultado = new TextBlock { Text = "En proceso.", FontSize = 22, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
            resultadoGrid.Children.Add(resultado);
            Grid.SetColumn(resultado, 1);

            Children.Add(resultadoGrid);
        }
开发者ID:douglaszuniga,项目名称:Gato,代码行数:28,代码来源:Cabecera.cs


示例4: DetectionButtonsControl

        public DetectionButtonsControl()
        {
            double imageWidth = 10;
            double imageHeight = 10;
            double buttonWidth;
            double smallDelimiter = 6 / 100 * imageWidth;
            double largeDelimiter = 8 / 100 * imageWidth;
            InitializeComponent();
            Button startButton = new Button();
            Button nextButton = new Button();
            Button backButton = new Button();
            Button stopButton = new Button();
            this.ButtonsStackPanel.Children.Add(startButton);
            this.ButtonsStackPanel.Children.Add(nextButton);
            this.ButtonsStackPanel.Children.Add(backButton);
            this.ButtonsStackPanel.Children.Add(stopButton);

            List<Button> buttons = new List<Button>();
            buttonWidth = (imageWidth - 2 * smallDelimiter - (buttons.Count - 1) * largeDelimiter) / buttons.Count;
            foreach (Button b in buttons)
            {

                if (buttons.IndexOf(b) == 1)
                {
                    //b.xPos = imageWidth + smallDelimiter;
                }
                else
                {
                    //b.xPos = imageWidth + largeDelimiter;
                }
            }
        }
开发者ID:kovacshuni,项目名称:slrt,代码行数:32,代码来源:DetectionButtonsControl.xaml.cs


示例5: DockAroundTheBlock

        public DockAroundTheBlock()
        {
            Title = "Dock Around the Block";

            // 1. �г� ���� �� �ʱ�ȭ
            DockPanel dock = new DockPanel();
            Content = dock;

            // 2. ���ϴ� �ڽ� ��ü(�̹���, ��Ʈ��, �г�..)
            for (int i = 0; i < 17; i++)
            {
                Button btn = new Button();
                btn.Content = "Button No. " + (i + 1);
                //-------------------------------------------------
                dock.Children.Add(btn);

                btn.SetValue(DockPanel.DockProperty, (Dock)(i % 4));

                DockPanel.SetDock(btn, (Dock)(i % 4));
                //-------------------------------------------------

            }

               // dock.LastChildFill = true;
            dock.LastChildFill = false;
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:26,代码来源:DockAroundTheBlock.cs


示例6: RegisterTaskPanes

 public void RegisterTaskPanes(Register register)
 {
     myAddinTaskPane = register(() =>
         {
             var button = new System.Windows.Controls.Button
             {
                 Content = "Insert Quote"
             };
             button.Click += InsertQuote;
             var host = new WpfPanelHost
             {
                 Child = new UserControl
                 {
                     Content = new StackPanel
                     {
                         Children =
                         {
                             button
                         }
                     }
                 }
             };
             return host;
         }, "Quotes!");
     myAddinTaskPane.Visible = true;
     myAddinTaskPane.VisibleChanged += TaskPaneVisibleChanged;
     TaskPaneVisibleChanged(this, EventArgs.Empty);
 }
开发者ID:JoyPeterson,项目名称:VSTOContrib,代码行数:28,代码来源:DocumentViewModel.cs


示例7: InitializeComponent

 public void InitializeComponent()
 {
     if (!this._contentLoaded)
     {
         this._contentLoaded = true;
         Application.LoadComponent(this, new Uri("/TWC.OVP;component/Controls/ErrorMessageBox.xaml", UriKind.Relative));
         this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
         this.DetailsEnabledStates = (VisualStateGroup) base.FindName("DetailsEnabledStates");
         this.ErrorMessageDetailDisabled = (VisualState) base.FindName("ErrorMessageDetailDisabled");
         this.ErrorMessageDetailEnabled = (VisualState) base.FindName("ErrorMessageDetailEnabled");
         this.DetailsStates = (VisualStateGroup) base.FindName("DetailsStates");
         this.DetailsVisible = (VisualState) base.FindName("DetailsVisible");
         this.DetailsNotVisible = (VisualState) base.FindName("DetailsNotVisible");
         this.BackgroundRectangle = (Rectangle) base.FindName("BackgroundRectangle");
         this.InnerDialogGrid = (Grid) base.FindName("InnerDialogGrid");
         this.DialogRectangle = (Rectangle) base.FindName("DialogRectangle");
         this.CloseButton = (Button) base.FindName("CloseButton");
         this.ErrorMessageTitleTextBlock = (TextBlock) base.FindName("ErrorMessageTitleTextBlock");
         this.ErrorMessageTextBlock = (TextBlock) base.FindName("ErrorMessageTextBlock");
         this.ButtonOK = (Button) base.FindName("ButtonOK");
         this.Icon = (TextBlock) base.FindName("Icon");
         this.SimpleErrorDetails = (Grid) base.FindName("SimpleErrorDetails");
         this.ShowDetailsToggle = (TextToggleButton) base.FindName("ShowDetailsToggle");
         this.DetailsTextBox = (TextBox) base.FindName("DetailsTextBox");
     }
 }
开发者ID:BigBri41,项目名称:TWCTVWindowsPhone,代码行数:26,代码来源:ErrorMessageBox.cs


示例8: showPopup2_Click

        private void showPopup2_Click(object sender, RoutedEventArgs e)
        {
            if (p.IsOpen == true)
                return;
            Border border = new Border();
            border.BorderBrush = new SolidColorBrush(Colors.White);
            border.BorderThickness = new Thickness(2.0);

            StackPanel panel1 = new StackPanel();

            Button button1 = new Button();
            button1.Content = "Close";
            button1.Margin = new Thickness(5.0);
            button1.Click += new RoutedEventHandler(button1_Click);
            TextBlock textblock1 = new TextBlock();
            textblock1.Text = "Premi il pulsante Close";
            textblock1.Margin = new Thickness(5.0);
            panel1.Children.Add(textblock1);
            panel1.Children.Add(button1);
            border.Child = panel1;

            p = new Popup();
            // Imposta la proprietà Child con il border che è il contenitore principale che contiene a sua volta uno stackpanel, un textblock ed un button.
            p.Child = border;
            //imposta la posizione del popup
            p.VerticalOffset = 100;
            p.HorizontalOffset = 50;

            // apre il popup
            p.IsOpen = true;
        }
开发者ID:zetanove,项目名称:Esempi_Silverlight4,代码行数:31,代码来源:MessagesPage.xaml.cs


示例9: AddCredit_Click

        private void AddCredit_Click(object sender, RoutedEventArgs e)
        {
            Credits.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            WrapPanel wp = new WrapPanel();
            Grid.SetRow(wp, Credits.RowDefinitions.Count - 1);
            Credits.Children.Add(wp);

            TextBox nameBox = new TextBox();
            nameBox.Name = creditname;
            nameBox.MinWidth = 170;
            wp.Children.Add(nameBox);

            Button saveButton = new Button();
            saveButton.Name = savebutton;
            saveButton.Height = 20;
            saveButton.Width = 20;
            saveButton.Margin = new Thickness(10, 0, 0, 0);
            saveButton.Click += new RoutedEventHandler(saveButton_Click);
            Image okImage = new Image();
            okImage.Source = Helpers.BitmapSourceFromBitmap(Exp1.Properties.Resources.ok);
            saveButton.Content = okImage;
            wp.Children.Add(saveButton);

            Button cancelButton = new Button();
            cancelButton.Name = cancelbutton;
            cancelButton.Height = 20;
            cancelButton.Width = 20;
            cancelButton.Margin = new Thickness(10, 0, 0, 0);
            cancelButton.Click += new RoutedEventHandler(cancelButton_Click);
            Image cancelImage = new Image();
            cancelImage.Source = Helpers.BitmapSourceFromBitmap(Exp1.Properties.Resources.cancel);
            cancelButton.Content = cancelImage;
            wp.Children.Add(cancelButton);
        }
开发者ID:asdanilenk,项目名称:Exp1,代码行数:35,代码来源:MainWindow.xaml.cs


示例10: SplitNine

        public SplitNine()
        {
            Title = "Split Nine";

            Grid grid = new Grid();
            Content = grid;

            // Set row and column definitions.
            for (int i = 0; i < 3; i++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                grid.RowDefinitions.Add(new RowDefinition());
            }

            // Create 9 buttons.
            for (int x = 0; x < 3; x++)
                for (int y = 0; y < 3; y++)
                {
                    Button btn = new Button();
                    btn.Content = "Row " + y + " and Column " + x;
                    grid.Children.Add(btn);
                    Grid.SetRow(btn, y);
                    Grid.SetColumn(btn, x);
                }

            // Create splitter.
            GridSplitter split = new GridSplitter();
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 1);
            Grid.SetColumn(split, 1);
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:32,代码来源:SplitNine.cs


示例11: Button

 //the button constructor
 public Button()
 {
     //initializing the button controll
     mButton = new System.Windows.Controls.Button();
     //set the view of the current widget as the previously instantiated button controll
     View = mButton;
 }
开发者ID:N00bKefka,项目名称:MoSync,代码行数:8,代码来源:MoSyncNativeUIWindowsPhone.cs


示例12: BasicsWindow

        public BasicsWindow()
        {
            Window basics = new Window
            {
                Title = "Code Basics",
                Height = 400,
                Width = 400,
                FontSize = 20,
            };

            StackPanel sp = new StackPanel();
            basics.Content = sp;

            TextBlock title = new TextBlock
            {
                Text = "Code Basics",
                FontSize = 24,
                TextAlignment = TextAlignment.Center,
            };
            sp.Children.Add(title);

            txtName = new TextBox();
            sp.Children.Add(txtName);
            txtName.Margin = new Thickness(10);

            Button btnSend = new Button
            {
                Content = "Send",
            };
            sp.Children.Add(btnSend);
            btnSend.Margin = new Thickness(10);
            btnSend.Click += BtnSend_Click;

            basics.Show();
        }
开发者ID:rnmisrahi,项目名称:JB,代码行数:35,代码来源:BasicsWindow.cs


示例13: updateBottomText

        private static void updateBottomText(Button btn, string newValue)
        {
            TextBlock lbl = UIHelper.GetChild<TextBlock>(btn, "PART_BottomText");

            if (lbl == null)
            {
                ContentPresenter c = UIHelper.GetChild<ContentPresenter>(btn);
                if (c != null && c.Parent is Panel)
                {
                    Panel p = c.Parent as Panel;

                    lbl = new TextBlock();
                    lbl.Name = "PART_BottomText";
                    lbl.Text = newValue;
                    lbl.HorizontalAlignment = HorizontalAlignment.Center;
                    lbl.VerticalAlignment = VerticalAlignment.Bottom;
                    lbl.Margin = new Thickness(-10, 0, -10, -13);
                    
                    updateBottomForeground(lbl, GetBottomTextForeground(btn));

                    p.Children.Add(lbl);
                }
                btn.Loaded -= btn_Loaded;
            }
            else
            {
                lbl.Text = newValue;
            }
        }
开发者ID:hihack,项目名称:CRM.Mobile,代码行数:29,代码来源:BottomTextHelper.cs


示例14: CreateWindowCommandRectangle

        /// <summary>
        /// Creates the window command rectangle.
        /// </summary>
        /// <param name="parentButton">The parent button.</param>
        /// <param name="style">The style.</param>
        /// <returns>Rectangle.</returns>
        public static Rectangle CreateWindowCommandRectangle(Button parentButton, string style)
        {
            Argument.IsNotNull(() => parentButton);
            Argument.IsNotNullOrWhitespace(() => style);

            var rectangle = new Rectangle
            {
                Width = 16d,
                Height = 16d,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Stretch = Stretch.UniformToFill
            };

            rectangle.SetBinding(Rectangle.FillProperty, new Binding("Foreground")
            {
                Source = parentButton
            });

            var application = Application.Current;
            if (application != null)
            {
                rectangle.OpacityMask = new VisualBrush
                {
                    //Stretch = Stretch.Fill,
                    Visual = application.FindResource(style) as Visual
                };
            }

            return rectangle;
        }
开发者ID:icygit,项目名称:Orchestra,代码行数:37,代码来源:WindowCommandHelper.cs


示例15: AbandonQuotePrice

 public void AbandonQuotePrice(QuotePriceClient quotePrice, QuotePriceForInstrument quotePriceForInstrument, bool isSigle, Button btn)
 {
     if (quotePriceForInstrument != null)
     {
         List<Answer> quoteQuotations = new List<Answer>();
         if (isSigle)
         {
             if (quotePrice != null)
             {
                 quoteQuotations.Add(quotePrice.ToSendQutoPrice());
             }
         }
         else
         {
             quoteQuotations = quotePriceForInstrument.GetSelectedQuotePriceForAccount();
         }
         if (quoteQuotations.Count > 0)
         {
             var AbandonQuoteEventLog = new EventLogEntity(Guid.NewGuid())
             {
                //write log
             };
         }
         //Notify service
         string exchangeCode = string.Empty;
         ConsoleClient.Instance.AbandonQuote(quoteQuotations);
     }
 }
开发者ID:BlueSky007,项目名称:ExchangeManager,代码行数:28,代码来源:QutePriceControl.xaml.cs


示例16: setCardBackgrounds

        public void setCardBackgrounds()
        {
            Random rng = new Random();
            var randBackgrounds = backgrounds; 
            //.OrderBy(a => rng.Next());
            for (int i = 0; i < cards.Count(); i++)
            {
                Button myButton = new Button
                {
                    Width = CardController.width,
                    Height = CardController.height,
                    Content = new Image
                    {
                        Source = new BitmapImage(new Uri(randBackgrounds.ElementAt(i % randBackgrounds.Count()))),
                        VerticalAlignment = VerticalAlignment.Center
                    }
                };
                myButton.Background = Brushes.Transparent;
                myButton.BorderBrush = Brushes.Black;

                Canvas.SetLeft(myButton, cards.ElementAt(i).rightXcoordinate);
                Canvas.SetTop(myButton, cards.ElementAt(i).topYcoordinate);
                cards.ElementAt(i).setButton(myButton);

                grid.Children.Add(cards.ElementAt(i).getButton());
            }
        }
开发者ID:EECS481MatchingGame,项目名称:GroupProject,代码行数:27,代码来源:BackgroundController.cs


示例17: ButtonElement

 public ButtonElement(string caption = null, EventHandler tapped = null)
     : base(caption, "dialog_button")
 {
     Click = tapped;
     _button = new Button();
     _button.Click += (s, e) => OnClick();
 }
开发者ID:runegri,项目名称:Android.Dialog,代码行数:7,代码来源:ButtonElement.cs


示例18: PlayGame

        /// <summary>
        /// Initializes gameplay phase
        /// </summary>
        /// <param name="difficulty">The chosen difficulty</param>
        /// <param name="buttons">The submitted placement of ships</param>
        /// <param name="name">The name of the player</param>
        public PlayGame(Difficulty difficulty, Button[] buttons, string name, Ship[] ships, MainWindow main)
        {
            InitializeComponent();

            this.main = main;
            // Set player name
            this.name = name.ToLower().Replace(' ', '_');

            // Set player and computer's ships
            shipsPlayer = ships;
            shipsComputer = new Ship[] {
                                        new Ship(ShipName.AIRCRAFT_CARRIER, 5),
                                        new Ship(ShipName.BATTLESHIP, 4),
                                        new Ship(ShipName.SUBMARINE, 3),
                                        new Ship(ShipName.CRUISER, 3),
                                        new Ship(ShipName.DESTROYER, 2)
            };

            // Set button field arrays
            buttonsPlayer = new Button[100];
            PlayerShips.Children.CopyTo(buttonsPlayer, 0);

            buttonsComputer = new Button[100];
            ComputerShips.Children.CopyTo(buttonsComputer, 0);

            common = new Common(ComputerShips, buttonsComputer);
            computerAI = new ComputerAI(this, difficulty);

            initializeGame(buttons);
        }
开发者ID:jeegnathebug,项目名称:BattleShip,代码行数:36,代码来源:PlayGame.xaml.cs


示例19: SelectColorFromWheel

        public SelectColorFromWheel()
        {
            Title = "Select Color from Wheel";
            SizeToContent = SizeToContent.WidthAndHeight;

            StackPanel stack = new StackPanel();
            stack.Orientation = Orientation.Horizontal;
            Content = stack;

            Button btn = new Button();
            btn.Content = "Do-nothing button\nto test tabbing";
            btn.Margin = new Thickness(24);
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment = VerticalAlignment.Center;
            stack.Children.Add(btn);

            ColorWheel clrwheel = new ColorWheel();
            clrwheel.Margin = new Thickness(24);
            clrwheel.HorizontalAlignment = HorizontalAlignment.Center;
            clrwheel.VerticalAlignment = VerticalAlignment.Center;
            stack.Children.Add(clrwheel);
            clrwheel.SetBinding(ColorWheel.SelectedValueProperty, "Background");
            clrwheel.DataContext = this;

            btn = new Button();
            btn.Content = "Do-nothing button\nto test tabbing";
            btn.Margin = new Thickness(24);
            btn.HorizontalAlignment = HorizontalAlignment.Center;
            btn.VerticalAlignment = VerticalAlignment.Center;
            stack.Children.Add(btn);
        }
开发者ID:JianchengZh,项目名称:kasicass,代码行数:31,代码来源:SelectColorFromWheel.cs


示例20: ButtonAutomationPeer

		public ButtonAutomationPeer (Button owner)
			: base (owner)
		{
			owner.Click += (s, a) => { 
				RaiseAutomationEvent (AutomationEvents.InvokePatternOnInvoked); 
			};
		}
开发者ID:shana,项目名称:moon,代码行数:7,代码来源:ButtonAutomationPeer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.Canvas类代码示例发布时间:2022-05-26
下一篇:
C# Controls.Border类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap