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


C# Grid.SetValue方法代码示例

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


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

示例1: PutToBottom

        public static void PutToBottom(Grid parent, Grid me, Grid source)
        {
            parent.ColumnDefinitions.Clear();
            parent.RowDefinitions.Clear();

            PhantasmagoriaSplitter splitter = new PhantasmagoriaSplitter()
            {
                VerticalAlignment = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Height = 8,
                Width = double.NaN
            };

            parent.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            parent.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(parent.ActualHeight * 0.5), MinHeight = MIN_HEIGHT });

            me.SetValue(Grid.RowProperty, 0);
            me.SetValue(Grid.RowSpanProperty, 1);
            me.Margin = new Thickness(0, 0, 0, 3);
            splitter.SetValue(Grid.RowProperty, 0);
            splitter.SetValue(Grid.RowSpanProperty, 1);
            splitter.Margin = new Thickness(0, 0, 0, -4);
            source.SetValue(Grid.RowProperty, 1);
            source.SetValue(Grid.RowSpanProperty, 1);
            source.Margin = new Thickness(0, 3, 0, 0);

            parent.Children.Add(me);
            parent.Children.Add(source);
            parent.Children.Add(splitter);
        }
开发者ID:ReijiPochi,项目名称:MatStudio,代码行数:30,代码来源:PhantasmagoriaTabControl.cs

示例2: BottomLeftMove

        private void BottomLeftMove(Grid grid, MouseEventArgs e)
        {
            var _point = getScreenRange(e.GetPosition(LayoutAreaCanvas));

            if (_point.Y > Height - 48)
                _point.Y = Height - 48;
            if (_point.Y < grid.Height - 16)
                _point.Y = grid.Height - 16;
            if (_point.X > Width - grid.Width)
                _point.X = Width - grid.Width;

            grid.SetValue(Canvas.TopProperty, (double)_point.Y - grid.Height + 32);
            grid.SetValue(Canvas.LeftProperty, (double)_point.X);

            // 横
            Line1.X1 = 32;
            Line1.Y1 = _point.Y;
            Line1.X2 = _point.X + 32;
            Line1.Y2 = _point.Y;

            Line2.X1 = _point.X + 32;
            Line2.Y1 = Height - 48;
            Line2.X2 = _point.X + 32;
            Line2.Y2 = _point.Y;
        }
开发者ID:RealPotSystems,项目名称:wGamePad,代码行数:25,代码来源:LayoutWindow.xaml.cs

示例3: SetRows

 /// <summary>
 /// Sets the value of <see cref="RowsProperty"/> for a given <see cref="Grid"/>.
 /// </summary>
 /// <param name="obj">The given <see cref="Grid"/>.</param>
 /// <param name="value">The new value of <see cref="RowsProperty"/>.</param>
 public static void SetRows(Grid obj, string value)
 {
     obj.SetValue(RowsProperty, value);
 }
开发者ID:k94ll13nn3,项目名称:KExtensions,代码行数:9,代码来源:KGrid.cs

示例4: CreerTerrain

        public Grid CreerTerrain()
        {
            var grid = new Grid();

            for (int x = 0; x < 17; x++)
                grid.ColumnDefinitions.Add(new ColumnDefinition());
            for (int y = 0; y < 20; y++)
                grid.RowDefinitions.Add(new RowDefinition());

            for (int x = 0; x < 20; x++)
                for (int y = 0; y < 17; y++)
                {
                    var childrenGrid = new Grid();
                    var border = new Border();

                    if (_plateauDeJeu.ZoneList.Exists(a => a.PositionX == x && a.PositionY == y))
                    {
                        var zone = _plateauDeJeu.ZoneList.First(a => a.PositionX == x && a.PositionY == y);

                        childrenGrid.DataContext = zone;

                        foreach (var objet in zone.ObjetList)
                        {
                            var binding = new Binding("Image");
                            border.SetBinding(Border.BackgroundProperty, binding);

                            if (objet is PacGomme)
                                zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\point.png", UriKind.Relative)));
                            if (objet is SuperPacGomme)
                                zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\pomme.png", UriKind.Relative)));
                            if (objet is Porte)
                                zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\porte.png", UriKind.Relative)));
                        }
                        childrenGrid.Children.Add(border);
                    }
                    else
                    {
                        border.Background = new SolidColorBrush(Colors.Red);
                        childrenGrid.Children.Add(border);
                    }

                    if (_plateauDeJeu.PersonnageList.Any(a => a.ZoneAbstraite.PositionX == x && a.ZoneAbstraite.PositionY == y))
                    {
                        var zone = _plateauDeJeu.ZoneList.First(a => a.PositionX == x && a.PositionY == y);
                        var personnage = _plateauDeJeu.PersonnageList.FirstOrDefault(a => a.ZoneAbstraite.PositionX == x && a.ZoneAbstraite.PositionY == y);
                        {
                            if (personnage is PacMan)
                                zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\Pacman.png", UriKind.Relative)));
                            if (personnage is Fantome)
                            {
                                var random = new Random();
                                var res = random.Next(1, 3);
                                switch (res)
                                {
                                    case 1:
                                        zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\Pacman-bleu.png", UriKind.Relative)));
                                        break;
                                    case 2:
                                        zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\Pacman-rose.png", UriKind.Relative)));
                                        break;
                                    case 3:
                                        zone.Image = new ImageBrush(new BitmapImage(new Uri("..\\Debug\\Ressources\\Pacman\\Pacman-rouge.png", UriKind.Relative)));
                                        break;
                                }
                            }
                        }
                    }

                    childrenGrid.SetValue(Grid.RowProperty, x);
                    childrenGrid.SetValue(Grid.ColumnProperty, y);
                    grid.Children.Add(childrenGrid);
                }
            return grid;
        }
开发者ID:lienafalionel,项目名称:Simulateur_Personnages,代码行数:74,代码来源:EnvironnementDeJeu.cs

示例5: SetSizeRowsToExpanderState

 public static void SetSizeRowsToExpanderState(Grid grid, bool value)
 {
     grid.SetValue(SizeRowsToExpanderStateProperty, value);
 }
开发者ID:gitter-badger,项目名称:OmniXAML,代码行数:4,代码来源:GridExpanderSizeBehavior.cs

示例6: CreateUserInterface

        private void CreateUserInterface()
        {
            #region Область размещения.
            grid_region.Children.Clear();
            grid_region.ColumnDefinitions.Clear();

            for (int i = 0; i < R.Dim; i++)
            {
                grid_region.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "dimension" });

                TextBox text_box = new TextBox();
                text_box.Text = region.Size(i).ToString();                
                text_box.SetValue(Grid.ColumnProperty, i);
                if (region.Freez(i))
                    text_box.Background = Brushes.Red;
                else
                    text_box.Background = Brushes.White;
                text_box.Tag = i;
                text_box.KeyDown += new System.Windows.Input.KeyEventHandler(TextBoxRegion_KeyDown);
                grid_region.Children.Add(text_box);
            }
            #endregion

            #region Объекты размещения.
            for (int i = 0; i < rects.Length; i++)
            {
                grid_rects.RowDefinitions.Add(new RowDefinition());

                Grid grid = new Grid();
                grid_rects.Children.Add(grid);
                grid.SetValue(Grid.RowProperty, i);
                grid.Tag = i;
                grid.MouseEnter += new System.Windows.Input.MouseEventHandler(GridRect_MouseEnter);
                for (int j = 0; j < R.Dim; j++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "dimension" });

                    Grid grid_ = new Grid();
                    grid.Children.Add(grid_);
                    grid_.SetValue(Grid.ColumnProperty, j);
                    grid_.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "value" });
                    grid_.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "value" });
                    grid_.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "value" });

                    TextBox text_box;

                    text_box = new TextBox();
                    text_box.Text = rects[i].Min(j).ToString();
                    text_box.IsReadOnly = true;
                    text_box.SetValue(Grid.ColumnProperty, 0);
                    grid_.Children.Add(text_box);

                    text_box = new TextBox();
                    text_box.Text = rects[i].Size(j).ToString();
                    //text_box.IsReadOnly = true;
                    text_box.SetValue(Grid.ColumnProperty, 1);
                    text_box.Tag = j;
                    text_box.KeyDown += new System.Windows.Input.KeyEventHandler(TextBoxRect_KeyDown);
                    grid_.Children.Add(text_box);

                    text_box = new TextBox();
                    text_box.Text = rects[i].Max(j).ToString();
                    text_box.IsReadOnly = true;
                    text_box.SetValue(Grid.ColumnProperty, 2);
                    grid_.Children.Add(text_box);
                }
            }
            #endregion
        }
开发者ID:Ring-r,项目名称:opt,代码行数:69,代码来源:MainWindow.xaml.cs

示例7: createGridLayout

        private Grid createGridLayout(double width, double height, out Grid grid, out TextBlock page)
        {
            grid=new Grid();
            Grid layout=new Grid();
            layout.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            layout.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            layout.Width = width;
            layout.Height = width;
            layout.Children.Add(grid);
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions[0].Height = new GridLength(50, GridUnitType.Pixel);
            grid.RowDefinitions[2].Height = new GridLength(15, GridUnitType.Pixel);
            grid.RowDefinitions[1].Height = new GridLength(height - 65, GridUnitType.Pixel);

            StackPanel headerPanel=new StackPanel();
            headerPanel.Height = 50;
            headerPanel.Background = new SolidColorBrush(Colors.LightGray);
            TextBlock header=new TextBlock();
            //header.Text = String.Format("{0} на {1}", GlobalStatus.Current.HomeHeader,DateTime.Now.ToString("dd.MM.yy HH:mm"));
            header.Text = "";
            header.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            header.FontSize = 13;
            headerPanel.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            grid.Children.Add(headerPanel);
            headerPanel.Children.Add(header);
            headerPanel.SetValue(Grid.RowProperty, 0);

            //host.Measure(new Size(width, double.PositiveInfinity));

            Grid footerGrid=new Grid();
            footerGrid.Height = 15;
            footerGrid.Background = new SolidColorBrush(Colors.LightGray);
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            footerGrid.ColumnDefinitions[0].Width = GridLength.Auto;
            footerGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
            footerGrid.ColumnDefinitions[2].Width = GridLength.Auto;
            footerGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            TextBlock footer=new TextBlock();
            footer.Text = String.Format("{0} на {1} ", GlobalStatus.Current.HomeHeader, DateTime.Now.ToString("HH:mm")); ;
            footer.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            footer.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            footer.FontSize = 12;
            footerGrid.Children.Add(footer);
            footer.SetValue(Grid.ColumnProperty, 1);

            page=new TextBlock();
            page.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            page.TextAlignment = TextAlignment.Left;
            page.FontSize = 12;
            footerGrid.Children.Add(page);
            page.SetValue(Grid.ColumnProperty, 0);

            TextBlock podp=new TextBlock();
            podp.Text = String.Format("{0}",  DateTime.Now.ToString("dd.MM.yy"));
            podp.TextAlignment = TextAlignment.Right;
            podp.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            podp.FontSize = 12;
            footerGrid.Children.Add(podp);
            podp.SetValue(Grid.ColumnProperty, 2);

            grid.Children.Add(footerGrid);
            footerGrid.SetValue(Grid.RowProperty, 2);

            return layout;
        }
开发者ID:rj128x,项目名称:VotGESOrders,代码行数:70,代码来源:Home.xaml.cs

示例8: Paint

        private void Paint(Size finalSize)
        {
            //maxValue = 100;
            var circleWidth = 4d;
            var pointWidth = 4d;
            var keduWidth = 1d;
            var keduLength = 5d;
            var standWidth = 3d;

            var startDegree = 290d;
            var standLength = 10d;
            var minValue = MinValue;
            var maxValue = MaxValue;
            if (minValue >= maxValue)
                return;
            //if (currenValue < minValue || currenValue > maxValue)
            //{
            //    currenValue = (minValue + maxValue) / 2;
            //}
            var widthSpan = 40d;
            var heightSpan = 20d;
            var width = finalSize.Width;
            var height = finalSize.Height;

            if (width < 100d || height < 50d)
            {
                this.Width = width = 100d;
                this.Height = height = 50d;
            }
            var centerX = (width - widthSpan) / 2d + heightSpan;
            var centerY = height - heightSpan + 10d;

            //Single MyWidth, MyHeight;
            //MyWidth = Width - widthSpan;
            //MyHeight = Height - heightSpan;
            //Single DI = 2 * MyHeight;
            //if (MyWidth < MyHeight)
            //{
            //    DI = MyWidth;
            //}

            var degreePerStandKeDu = (720d - 2d * startDegree) / 5d;  //计算出每个标准大刻度之间的角度
            var degreePerKeDu = degreePerStandKeDu / 5d;
            var valuePerKeDu = (maxValue - minValue) / 5;  //每个大刻度之间的值

            //Rectangle MyRect;
            //g = e.Graphics;
            //g.Clear(this.BackColor);
            //g.DrawRectangle(new Pen(Color.Black, 2), 2, 2, this.Width - 4, this.Height - 4);
            _background.SetValue(WidthProperty, width);
            _background.SetValue(HeightProperty, height);

            //MyRect = new Rectangle(0, 0, this.Width, this.Height);
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            ////将绘图平面的坐标原点移到窗口中心
            //g.TranslateTransform(MyWidth / 2 + heightSpan, MyHeight + 10);
            //绘制表盘
            //g.FillEllipse(Brushes.Black,MyRect);
            //string word = currenValue.ToString().Trim() + title;
            //int len = ((word.Trim().Length) * (myFont.Height)) / 2;
            //g.DrawString(word.Trim(), myFont, Brushes.Red, new PointF(-len / 2, -MyHeight / 2 - myFont.Height / 2));
            Size textSize = _text.MeasureTextSize();
            _text.SetValue(Canvas.LeftProperty, centerX - textSize.Width / 2d);
            _text.SetValue(Canvas.TopProperty, centerY - (height - heightSpan - textSize.Height) / 2d);

            //g.RotateTransform(startDegree);
            //绘制刻度标记
            _calibrationCanvas.Children.Clear();
            var calibrationBrush = new SolidColorBrush(Colors.Green);
            _calibrationCanvas.Background = calibrationBrush;
            var calibrationLeft = centerX - 2d;
            var calibrationTop = centerY + 2d - height + heightSpan;
            var calibrationDegree = startDegree;
            var origin = new Point(0.5d, (centerY - calibrationTop) / keduLength);
            for (int x = 0; x < 26; x++)
            {
                //g.FillRectangle(Brushes.Green, new Rectangle(-2, (System.Convert.ToInt16(DI) / 2 - 2) * (-1), keduWidth, keduLength));
                //g.RotateTransform(degreePerKeDu);
                var calibrationLine = new Rectangle();
                calibrationLine.SetValue(Canvas.LeftProperty, calibrationLeft);
                calibrationLine.SetValue(Canvas.TopProperty, calibrationTop);
                calibrationLine.SetValue(WidthProperty, keduWidth);
                calibrationLine.SetValue(HeightProperty, keduLength);
                calibrationLine.Fill = calibrationBrush;
                calibrationLine.RenderTransformOrigin = origin;
                calibrationLine.RenderTransform = new RotateTransform() { Angle = calibrationDegree, };
                _calibrationCanvas.Children.Add(calibrationLine);
                calibrationDegree += degreePerKeDu;
            }
            ////重置绘图平面的坐标变换
            //g.ResetTransform();
            //g.TranslateTransform(MyWidth / 2 + heightSpan, MyHeight + 10);
            //g.RotateTransform(startDegree);
            //mySpeed = minValue;
            ////绘制刻度值
            var speed = minValue;
            var labelBrush = new SolidColorBrush(Colors.Red);
            var lableLineLeft = centerX - 3d;
            var lableLineTop = centerY + 2d - height + heightSpan;
            var labelTop = centerY - (height - heightSpan) + 26d;
//.........这里部分代码省略.........
开发者ID:Jitlee,项目名称:WPFMonitor,代码行数:101,代码来源:DLBiaoPan.cs

示例9: Safety

 //操作安全判断
 private void Safety(object sender, RoutedEventArgs e)
 {
     TreeViewItem tvi = ((sender as TreeView).SelectedItem as TreeViewItem);
     string save = tvi.Uid.ToString();
     if (save == null || "".Equals(save)) return;
     if (save.Equals("loginDiary"))
     {
         Grid saveGrid = new Grid();
         showGrid.Children.Add(saveGrid);
         saveGrid.SetValue(Grid.RowProperty, 0);
         saveGrid.SetValue(Grid.ColumnProperty, 1);
         saveGrid.Background = Brushes.DarkCyan;
     }
     else
     {
         Grid saveGrid = new Grid();
         showGrid.Children.Add(saveGrid);
         saveGrid.SetValue(Grid.RowProperty, 0);
         saveGrid.SetValue(Grid.ColumnProperty, 1);
         saveGrid.Background = Brushes.DarkOrchid;
     }
 }
开发者ID:uwitec,项目名称:gloryview-rfid,代码行数:23,代码来源:MainForm.xaml.cs

示例10: TopRightMove

        private void TopRightMove(Grid grid, MouseEventArgs e)
        {
            var _point = getScreenRange(e.GetPosition(LayoutAreaCanvas));

            if (_point.Y > Height - grid.Height - 16)
                _point.Y = Height - grid.Height - 16;
            if (_point.X > Width - 32)
                _point.X = Width - 32;
            if (_point.X < grid.Width - 32)
                _point.X = grid.Width - 32;

            grid.SetValue(Canvas.TopProperty, (double)_point.Y);
            grid.SetValue(Canvas.LeftProperty, (double)_point.X - grid.Width + 32 );

            // 横
            Line1.X1 = Width - 32;
            Line1.Y1 = _point.Y + 32;
            Line1.X2 = _point.X;
            Line1.Y2 = _point.Y + 32;

            // 縦
            Line2.X1 = _point.X;
            Line2.Y1 = 48;
            Line2.X2 = _point.X;
            Line2.Y2 = _point.Y + 32;
        }
开发者ID:RealPotSystems,项目名称:wGamePad,代码行数:26,代码来源:LayoutWindow.xaml.cs

示例11: GenerateControls


//.........这里部分代码省略.........
                }
                else if (!property.CanWrite) continue;
                else if (type == typeof(string)) {
                    control = new TextBox();
                    bindProperty = TextBox.TextProperty;
                }
                else if (type.IsNumericType()) {
                    control = new NumericUpDown();
                    bindProperty = NumericUpDown.ValueProperty;
                }
                else if (type == typeof (bool) 
                        || (genericType != null && genericType == typeof(Nullable<>) && genericType.GenericTypeArguments[0] == typeof(bool))) {
                    control = new ToggleSwitch {Language = Language};
                    bindProperty = ToggleSwitch.IsCheckedProperty;
                }

                if (control != null && bindProperty != null) {
                    if (firstControl == null) firstControl = control;

                    var displayAttr = property.GetAttribute<DisplayAttribute>();
                    string displayValue;
                    string description;
                    string groupName;
                    if (displayAttr != null) {
                        displayValue = displayAttr.GetName() ?? property.Name;
                        description = displayAttr.GetDescription() ?? string.Empty;
                        groupName = displayAttr.GetGroupName() ?? string.Empty;
                    }
                    else {
                        displayValue = property.Name;
                        description = string.Empty;
                        groupName = string.Empty;
                    }

                    var textBlock = new TextBlock();
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                    textBlock.Margin = new Thickness(10);
                    textBlock.Text = displayValue;
                    if (!string.IsNullOrEmpty(description))
                        textBlock.ToolTip = description;
                    textBlock.SetCurrentValue(Grid.ColumnProperty, 0);

                    control.Margin = new Thickness(10);
                    control.SetCurrentValue(Grid.ColumnProperty, 1);

                    var binding = new Binding();
                    binding.Source = settings;
                    binding.Path = new PropertyPath(propertyPath);
                    binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
                    var bindingExpression = BindingOperations.SetBinding(control, bindProperty, binding);
                    _bindings.Add(bindingExpression);

                    if (groups.ContainsKey(groupName))
                        groups[groupName].Add(textBlock, control);
                    else
                        groups.Add(groupName, new Dictionary<TextBlock, Control> {{textBlock, control}});
                }
            }

            foreach (var group in groups) {
                var tabItem = new TabItem();
                if (groups.Count > 1)
                    tabItem.Header = string.IsNullOrEmpty(group.Key) ? Novaroma.Properties.Resources.Main : group.Key;
                ControlsTabControl.Items.Add(tabItem);

                var scrollViewer = new ScrollViewer();
                tabItem.Content = scrollViewer;

                var grid = new Grid();
                grid.HorizontalAlignment = HorizontalAlignment.Stretch;
                grid.VerticalAlignment = VerticalAlignment.Stretch;
                grid.Margin = new Thickness(20);
                grid.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
                grid.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
                grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(0, GridUnitType.Auto)});
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                scrollViewer.Content = grid;

                var i = 0;
                foreach (var controls in group.Value) {
                    var rowDefinition = new RowDefinition();
                    rowDefinition.Height = new GridLength(0, GridUnitType.Auto);
                    grid.RowDefinitions.Add(rowDefinition);

                    var textBlock = controls.Key;
                    textBlock.SetCurrentValue(Grid.RowProperty, i);

                    var control = controls.Value;
                    control.SetCurrentValue(Grid.RowProperty, i);

                    grid.Children.Add(controls.Key);
                    grid.Children.Add(controls.Value);

                    i++;
                }
            }

            if (firstControl != null)
                firstControl.Focus();
        }
开发者ID:XMotoGodX,项目名称:novaroma,代码行数:101,代码来源:SettingsWindow.xaml.cs

示例12: SetTimetable

        // Organises the table for a given user on a particular day
        public void SetTimetable(User CurrentUser, DateTime Day)
        {
            // Get the current database state
            DataSnapshot Frame = DataRepository.TakeSnapshot();

            // Generate the correct number of rows
            Container.RowDefinitions.Clear();
            // Top header row
            Container.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
            // Actual rows of the table
            for (int y = 0; y < Frame.Rooms.Count; y++)
                Container.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(TileHeight) });

            // Generate the columns
            Container.ColumnDefinitions.Clear();
            // Left-hand side-heading column
            Container.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(LeftWidth) });
            // Actual columns in the table
            for (int x = 0; x < Frame.Periods.Count; x++)
                Container.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(TileWidth) });

            // Add the left-hand bar, contains room names and a tooltip
            Container.Children.Clear();
            for (int y = 0; y < Frame.Rooms.Count; y++)
            {
                // Create a textblock displaying the room name
                TextBlock Child = new TextBlock();
                Child.Text = Frame.Rooms[y].RoomName;
                // Set standard font, margin, wrapping style etc
                Child.FontSize = 16;
                Child.Margin = new Thickness(0, 0, 5, 0);
                Child.TextWrapping = TextWrapping.Wrap;
                Child.VerticalAlignment = VerticalAlignment.Center;
                Child.HorizontalAlignment = HorizontalAlignment.Right;

                // Create the alignment control for nice layout
                Border LeftTile = new Border();
                // Set tooltip to useful information
                LeftTile.ToolTip = "Standard Seats: " + Frame.Rooms[y].StandardSeats + (Frame.Rooms[y].SpecialSeats == 0 ? "" : "\n" + Frame.Rooms[y].SpecialSeatType + ": " + Frame.Rooms[y].SpecialSeats);
                // Set the UI child of this control to be the texblock above
                LeftTile.Child = Child;
                // Background colour
                LeftTile.Background = MarginBrush;

                // Positioning on the layout grid
                LeftTile.SetValue(Grid.RowProperty, y + 1);
                LeftTile.SetValue(Grid.ColumnProperty, 0);

                // Add the controls to the grid
                Container.Children.Add(LeftTile);
            }

            // Add the top heading, contains timeslot name and time interval
            for (int x = -1; x < Frame.Periods.Count; x++)
            {
                // Use a grid for ease of layout
                Grid TopTile = new Grid();
                TopTile.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
                TopTile.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });

                // Set background and child alignments
                TopTile.Background = MarginBrush;
                TopTile.VerticalAlignment = VerticalAlignment.Bottom;
                TopTile.HorizontalAlignment = HorizontalAlignment.Left;

                // If we're not filling out the top-left corner cell, store the timeslot name
                string Text = "";
                if (x >= 0 && !string.IsNullOrWhiteSpace(Frame.Periods[x].Name))
                    Text = Frame.Periods[x].Name;

                // First textblock - timeslot name
                TopTile.Children.Add(new TextBlock() { Text = Text, FontSize = 16, Margin = new Thickness(2, 2, 2, 0), TextWrapping = TextWrapping.Wrap, Width = TileWidth });
                // Second textblock - timeslot duration
                TopTile.Children.Add(new TextBlock() { Text = x >= 0 ? Frame.Periods[x].TimeRange : "", FontSize = 16, Margin = new Thickness(2, 0, 2, 10), TextWrapping = TextWrapping.Wrap, Width = TileWidth });

                // Set the position of each textblock within the local grid
                for (int y = 0; y < TopTile.Children.Count; y++)
                    TopTile.Children[y].SetValue(Grid.RowProperty, y);

                // Algin the local grid within the table's grid
                TopTile.SetValue(Grid.RowProperty, 0);
                TopTile.SetValue(Grid.ColumnProperty, x + 1);
                Container.Children.Add(TopTile);
            }

            // Add the main content
            // Find bookings on this day
            List<Booking> RelevantBookings = Frame.Bookings.Where(b => b.MatchesDay(Day)).ToList();
            // Initialise the internal array of tiles
            Tiles = new TimetableTile[Frame.Rooms.Count, Frame.Periods.Count];
            for (int y = 0; y < Frame.Rooms.Count; y++)
            {
                for (int x = 0; x < Frame.Periods.Count; x++)
                {
                    // Get the booking (or null) for this combination of room and timeslot
                    Booking Current = RelevantBookings.Where(b => b.TimeSlot == Frame.Periods[x] && b.Rooms.Contains(Frame.Rooms[y])).SingleOrDefault();

                    // Create the timetable tile
                    Tiles[y, x] = new TimetableTile(Current, Frame.Periods[x], Frame.Rooms[y], CurrentUser);
//.........这里部分代码省略.........
开发者ID:hnefatl,项目名称:Prototype1,代码行数:101,代码来源:TimetableDisplay.xaml.cs

示例13: SetDecrementKeyGesture

 public static void SetDecrementKeyGesture(Grid grid, KeyGesture gesture)
 {
     Guard.ArgumentNotNull(grid, "grid");
     grid.SetValue(DecrementKeyGestureProperty, gesture);
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:5,代码来源:GridSplitterKeyAccelerator.cs

示例14: SetTargetColumn

 public static void SetTargetColumn(Grid grid, int columnIndex)
 {
     Guard.ArgumentNotNull(grid, "grid");
     grid.SetValue(TargetColumnProperty, columnIndex);
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:5,代码来源:GridSplitterKeyAccelerator.cs

示例15: InitPopup

        private void InitPopup()
        {
            popup = new Popup();
            popup.Opened += popup_Opened;

            Binding backgroundBinding = new Binding("Background");
            backgroundBinding.Source = this;

            Binding foregroundBinding = new Binding("Foreground");
            foregroundBinding.Source = this;

            Grid border = new Grid();
            border.Background = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0));
            border.Width = Application.Current.Host.Content.ActualWidth;
            border.Height = Application.Current.Host.Content.ActualHeight;

            Grid container = new Grid();
            CompositeTransform transform = new CompositeTransform()
            {
                TranslateY = -Application.Current.Host.Content.ActualHeight
            };
            container.RenderTransform = transform;
            container.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            container.SetBinding(Grid.BackgroundProperty, backgroundBinding);

            #region init grid rows

            RowDefinition row1 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            container.RowDefinitions.Add(row1);

            RowDefinition row2 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            container.RowDefinitions.Add(row2);

            RowDefinition row3 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            container.RowDefinitions.Add(row3);

            #endregion

            TextBlock title = new TextBlock()
            {
                Margin = new Thickness(12),
                FontSize = 30,
                FontWeight = FontWeights.Black
            };
            Binding titleBinding = new Binding("Title");
            titleBinding.Source = this;
            title.SetBinding(TextBlock.TextProperty, titleBinding);

            title.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
            container.Children.Add(title);

            TextBlock content = new TextBlock()
            {
                Margin = new Thickness(12),
                FontSize = 26,
                FontWeight = FontWeights.Medium
            };

            Binding contentBinding = new Binding("Content");
            contentBinding.Source = this;
            content.SetBinding(TextBlock.TextProperty, contentBinding);

            content.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
            content.SetValue(Grid.RowProperty, 1);
            container.Children.Add(content);

            switch (MessageBoxButtons)
            {
                case MessageBoxButton.OK:
                    {
                        Button btn = new Button()
                        {
                            Content = "OK",
                            Margin = new Thickness(0, 0, 0, 10)
                        };

                        btn.Click += (s, args) =>
                        {
                            var handler = OKClick;
                            if (null != handler)
                            {
                                handler(this, new RoutedEventArgs());
                            }

                            GetCloseAnimation();
                        };

                        btn.SetValue(Grid.RowProperty, 2);
                        container.Children.Add(btn);
                    }
                    break;
//.........这里部分代码省略.........
开发者ID:kjiwu,项目名称:WP_CustomControls,代码行数:101,代码来源:MyMessageBox.cs


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