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


C# Button.SetValue方法代码示例

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


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

示例1: AddButtons

        private void AddButtons()
        {
            if (string.IsNullOrWhiteSpace(size1.Text)) size = 10;
            else size = Int32.Parse(size1.Text);// * Int32.Parse(size1.Text);

            for (int k = 0; k < size; k++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                grid.RowDefinitions.Add(new RowDefinition());
            }

            bs = new Button[size, size];

               // grid_buttons = new List<List<Button>>();
             for (int i = 0; i < grid.RowDefinitions.Count; ++i)
                {
                 for (int j = 0; j < grid.ColumnDefinitions.Count; ++j)
                 {
                     button = new Button();
                     button.SetValue(Grid.RowProperty, i);
                     button.SetValue(Grid.ColumnProperty, j);
                     button.Background = new SolidColorBrush(Colors.White);
                     button.Click += ChangeState;
                    button.Focusable = false;

                         grid.Children.Add(button);
                       //  grid_buttons[i][j] = button;
                         bs[i, j] = button;

             }
                 }
        }
开发者ID:yulia-b,项目名称:CellularAutomaton,代码行数:32,代码来源:MainGUI.xaml.cs

示例2: GridWindow

        public GridWindow()
        {
            Title = "Grid window";
            Height = 400;
            Width = 400;
            FontSize = 20;

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

            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());

            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            Button btn = new Button
            {
                Content = "Click Me",
                FontSize = 15,
            };

            grid.Children.Add(btn); // Add button to grid

            btn.SetValue(Grid.RowProperty, 1); // Register button to Row and Column dependency properties
            btn.SetValue(Grid.ColumnProperty, 1);
        }
开发者ID:rnmisrahi,项目名称:JB,代码行数:29,代码来源:GridWindow.cs

示例3: CreateAndAddButton

        private void CreateAndAddButton(int row, int column, Type controlType)
        {
            var button = new Button();
            button.SetValue(Grid.RowProperty, row);
            button.SetValue(Grid.ColumnProperty, column);
            button.Content = controlType.Name;
            MainGrid.Children.Add(button);

            WireEvents(button, controlType);
        }
开发者ID:paulomouat,项目名称:spikes,代码行数:10,代码来源:MainWindow.xaml.cs

示例4: GreenGUI

        Int32 turns = 0; // 0 if it is my turn, 1 if the opponent's

        #endregion Fields

        #region Constructors

        // Constructs the UserControl GreenGUI
        // _quatro: this object holds all of the game data the can be queried
        public GreenGUI()
        {
            InitializeComponent();

            // Load images
            for (int i = 0; i < 16; i++)
            {
                Image im = new Image();
                im.Source = new BitmapImage(new Uri(@"Images/piece-" + i + ".png", UriKind.Relative));
                images[i] = im;
            }
            imageEmpty = new Image();
            imageEmpty.Source = new BitmapImage(new Uri(@"Images/empty.png", UriKind.Relative));
            imageUnknown = new Image();
            imageUnknown.Source = new BitmapImage(new Uri(@"Images/unknown.png", UriKind.Relative));

            // Create buttons (area)
            for (int i = 0; i < 16; i++)
            {
                Button b = new Button();
                b.Click += BtPut_Click;
                b.Tag = i;
                gameArea.Children.Add(b);
                Image im = new Image();
                im.Source = imageEmpty.Source;
                b.Content = im;
                b.SetValue(Grid.RowProperty, i/4);
                b.SetValue(Grid.ColumnProperty, i%4);
                area[i/4,i%4] = b;
            }

            // Create buttons (available)
            for (int i = 0; i < 16; i++)
            {
                Button b = new Button();
                b.Click += BtChoose_Click;
                b.Tag = i;
                gameArea.Children.Add(b);
                Image im = new Image();
                im.Source = images[i].Source;
                b.Content = im;
                b.SetValue(Grid.RowProperty, i / 4);
                b.SetValue(Grid.ColumnProperty, i % 4);
                available[i/4,i%4] = b;
            }

            // Set the two player string
            players = new String[2] { "You", "Opponent" };

            // Displays who turns next
            ShowNextEvent();
        }
开发者ID:porcellus,项目名称:KomponensAlapuJatek,代码行数:60,代码来源:GreenGUI.xaml.cs

示例5: LoadArea

        public void LoadArea(int fieldId)
        {
            AreaCanvas.Children.Clear();
            AreaInfoStackPanel.Visibility = Visibility.Collapsed;
            Task<List<QuestAreaMaster>> task = new Task<List<QuestAreaMaster>>(() =>
            {
                return DAL.ToList<QuestAreaMaster>(string.Format("SELECT * FROM QUEST_AREA_MASTER WHERE parent_field_id={0} ORDER BY ID", fieldId));
            });
            task.ContinueWith(t =>
            {
                if (t.Exception != null)
                {
                    Utility.ShowException(t.Exception);
                    return;
                }
                foreach (var qam in t.Result)
                {
                    var btn = new Button()
                    {
                        Width = qam.icon_col_w * SCALE_PARAMETER,
                        Height = qam.icon_col_h * SCALE_PARAMETER,
                        Content = new TextBlock()
                        {
                            Text = qam.name,
                            TextWrapping = TextWrapping.Wrap
                        },
                    };
                    btn.SetValue(Canvas.LeftProperty, (qam.icon_pos_x - qam.icon_col_w/2)*SCALE_PARAMETER + LEFT_OFFSET);
                    btn.SetValue(Canvas.TopProperty, (qam.icon_pos_y - qam.icon_col_h/2)*SCALE_PARAMETER + TOP_OFFSET);
                    btn.SetValue(Grid.ZIndexProperty, 128);
                    btn.Click += (e, s) =>
                    {
                        LoadAreaInfo(qam);
                        if (qam.move_field_id > 0)
                        {
                            LoadArea((int)qam.move_field_id);
                        }
                    };
                    AreaCanvas.Children.Add(btn);
                    QuestAreaMaster nextQam = t.Result.Find(o => o.id == qam.connect_area_id);
                    if (nextQam != null)
                    {
                        AreaCanvas.Children.Add(GetAreaLine(qam, nextQam));
                    }

                }
            }, MainWindow.UiTaskScheduler);    //this Task work on ui thread
            task.Start();
        }
开发者ID:WindWT,项目名称:RTDDE.Executer,代码行数:49,代码来源:Area.xaml.cs

示例6: LoadField

 public void LoadField(int worldId)
 {
     Task<List<QuestFieldMaster>> task = new Task<List<QuestFieldMaster>>(() =>
     {
         return DAL.ToList<QuestFieldMaster>(string.Format("SELECT * FROM QUEST_FIELD_MASTER WHERE parent_world_id={0} ORDER BY ID", worldId));
     });
     task.ContinueWith(t =>
     {
         if (t.Exception != null)
         {
             Utility.ShowException(t.Exception);
             return;
         }
         FieldCanvas.Children.Clear();
         foreach (var qfm in t.Result)
         {
             //Add field
             var btn = new Button()
             {
                 Width = qfm.icon_col_w * SCALE_PARAMETER,
                 Height = qfm.icon_col_h * SCALE_PARAMETER,
                 Content = new TextBlock()
                 {
                     Text = qfm.name_short,
                     TextWrapping = TextWrapping.Wrap
                 },
             };
             btn.Click += (sender, e) =>
             {
                 Area.LoadArea((int)qfm.id);
                 LoadFieldInfo(qfm);
             };
             btn.SetValue(Canvas.LeftProperty, (double)qfm.icon_pos_x * SCALE_PARAMETER + LEFT_OFFSET);
             btn.SetValue(Canvas.TopProperty, (double)qfm.icon_pos_y * SCALE_PARAMETER + TOP_OFFSET);
             FieldCanvas.Children.Add(btn);
             //Add line between field
             if (qfm.arrow_type > 0)
             {
                 var lineCanvas = GetArrowCanvas(qfm.arrow_type, qfm.arrow_rotate, qfm.arrow_reverse);
                 lineCanvas.SetValue(Canvas.LeftProperty, qfm.arrow_pos_x * SCALE_PARAMETER + LEFT_OFFSET + 25);   //use magic number 25, hope won't break in 17 years
                 lineCanvas.SetValue(Canvas.TopProperty, qfm.arrow_pos_y * SCALE_PARAMETER + TOP_OFFSET);
                 lineCanvas.SetValue(Grid.ZIndexProperty, 128);
                 FieldCanvas.Children.Add(lineCanvas);
             }
         }
     }, MainWindow.UiTaskScheduler);    //this Task work on ui thread
     task.Start();
 }
开发者ID:WindWT,项目名称:RTDDE.Executer,代码行数:48,代码来源:Field.xaml.cs

示例7: 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

示例8: Bug484164

 public void Bug484164()
 {
     Button b = new Button { Content = "Button" };
     string n = "Bob";
     b.SetValue(FrameworkElement.NameProperty, n);
     TestPanel.Children.Add(b);
     Assert.IsNotNull(b.FindName(n));
 }
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:8,代码来源:TestPanel.cs

示例9: PopulateBottomRow

        private Grid PopulateBottomRow(int row, Grid grid)
        {
            var cancelButton = new Button();
            cancelButton.Content = "Cancel";
            cancelButton.Click += CloseWindow;

            grid.Children.Add(cancelButton);
            cancelButton.SetValue(Grid.RowProperty, row);
            return grid;
        }
开发者ID:richhildebrand,项目名称:PuzzleRpg,代码行数:10,代码来源:CastSpellModal.cs

示例10: CreateUserControlElements

 public void CreateUserControlElements()
 {
     Button myEndTestButton = new Button();
     Button myNextButton = new Button();
     Button myPreviousButton = new Button();
     myEndTestButton.Content = "Закночить тестирование";
     myEndTestButton.Click += EndTestClick;
     myEndTestButton.SetValue(Grid.ColumnProperty, 1);
     userControlGrid.Children.Add(myEndTestButton);
 }
开发者ID:Nexword,项目名称:DescSTE,代码行数:10,代码来源:STEWindow.cs

示例11: Bug484164b

 public void Bug484164b()
 {
     Button b = new Button { Content = "Button" };
     string n = "Bob";
     b.SetValue(FrameworkElement.NameProperty, n);
     TestPanel.Children.Add(b);
     EnqueueDelay(TimeSpan.FromSeconds(.2));
     EnqueueCallback(() => Assert.IsNotNull(b.FindName(n)));
     EnqueueTestComplete();
 }
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:10,代码来源:TestPanel.cs

示例12: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = new Button();
            btn.Width = 160;
            btn.Height = 80;
            btn.Content = "后台添加的";

            btn.SetValue(Canvas.ZIndexProperty, 1);
            btn.RenderTransform = new CompositeTransform();
            btn.ManipulationDelta += textBlock_ManipulationDelta;
            LayoutRoot.Children.Add(btn);
        }
开发者ID:hj458377603,项目名称:MediaAlbum,代码行数:12,代码来源:MainPage.xaml.cs

示例13: DockAroundTheBlock

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

            DockPanel dock = new DockPanel();
            Content = dock;
            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));
            }
        }
开发者ID:JianchengZh,项目名称:kasicass,代码行数:14,代码来源:DockAroundTheBlock.cs

示例14: AddButtons

        private void AddButtons()
        {
            for (int i = 0; i < 25; ++i)
            {
                Button button = new Button();
                button.SetValue(Grid.ColumnProperty, i);
                button.Background = new SolidColorBrush(Colors.White);

                grid_neigh.Children.Add(button);
                button.Click += ChangeState;
                button.Focusable = false;
                buttons.Add(button);
            }
        }
开发者ID:yulia-b,项目名称:CellularAutomaton,代码行数:14,代码来源:RulesGUI.xaml.cs

示例15: Add_Click

 private void Add_Click(object sender, RoutedEventArgs e)
 {
     Button b = new Button();
     b.Content = DateTime.Now.Millisecond;
     b.Padding = new Thickness(5);
     b.SetValue(ComponentFactory.Quicksilver.Layout.CanvasLayout.LeftProperty, (double)_random.Next(300));
     b.SetValue(ComponentFactory.Quicksilver.Layout.CanvasLayout.TopProperty, (double)_random.Next(300));
     b.SetValue(ComponentFactory.Quicksilver.Layout.DockLayout.DockProperty, (Dock)_random.Next(4));
     b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.ColumnProperty, _random.Next(16));
     b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.RowProperty, _random.Next(16));
     b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.ColumnSpanProperty, _random.Next(2) + 1);
     b.SetValue(ComponentFactory.Quicksilver.Layout.GridLayout.RowSpanProperty, _random.Next(2) + 1);
     TargetPanel.Children.Insert(_random.Next(TargetPanel.Children.Count), b);
 }
开发者ID:ComponentFactory,项目名称:Quicksilver,代码行数:14,代码来源:MetaGridPanel.xaml.cs


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