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


C# Grid.UpdateLayout方法代码示例

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


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

示例1: ExportToString

        /// <summary>
        /// Export the specified plot model to an xaml string.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        /// <returns>A xaml string.</returns>
        public static string ExportToString(PlotModel model, double width, double height, OxyColor background = null)
        {
            var g = new Grid();
            if (background != null)
            {
                g.Background = background.ToBrush();
            }

            var c = new Canvas();
            g.Children.Add(c);

            var size = new Size(width, height);
            g.Measure(size);
            g.Arrange(new Rect(0, 0, width, height));
            g.UpdateLayout();

            var rc = new ShapesRenderContext(c) { UseStreamGeometry = false };
            model.Update();
            model.Render(rc, width, height);

            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
                XamlWriter.Save(c, xw);
            }

            return sb.ToString();
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:37,代码来源:XamlExporter.cs

示例2: InitalizeGrid

        /// <summary>
        ///     Разлинеивает таблицу
        /// </summary>
        /// <param name="grid">Таблица</param>
        /// <param name="column">Количество колонок</param>
        /// <param name="row">Количество строчек</param>
        public static void InitalizeGrid(Grid grid, int column, int row)
        {
            for (int i = 0; i < column; i++)
            {
                for (int j = 0; j < row; j++)
                {
                    var rectengle = new Rectangle { Stroke = StrokeColor, StrokeThickness = 0 };

                    Grid.SetColumn(rectengle, i);
                    Grid.SetRow(rectengle, j);
                    grid.Children.Add(rectengle);
                    grid.UpdateLayout();
                }
            }
        }
开发者ID:Confirmit,项目名称:Students,代码行数:21,代码来源:WorkWirhGrid.cs

示例3: InitGrid

        private static void InitGrid(Grid grid, DtoTableViewModel vm)
        {
            if (vm != null && grid != null)
            {
                grid.RowDefinitions.Clear();
                grid.ColumnDefinitions.Clear();
                foreach (var row in vm.Rows)
                {
                    grid.RowDefinitions.Add(new RowDefinition());
                }
                foreach (var col in vm.Columns)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "col" + col.Column.ToString() });
                }

                grid.InvalidateArrange();
                grid.UpdateLayout();
            }
        }
开发者ID:daszat,项目名称:zetbox,代码行数:19,代码来源:DtoDisplayer.xaml.cs

示例4: RenderAndSave

        public void RenderAndSave(ImageRendererArguments args, out string fileName)
        {
            var mainContainer = new Grid();

            mainContainer.Children.Add(args.UiContainer);
            mainContainer.Measure(new Size(args.Width, args.Height));
            mainContainer.Arrange(new Rect(0, 0, args.Width, args.Height));
            mainContainer.UpdateLayout();

            var encoder = new PngBitmapEncoder();
            var render = RenderBitmap(mainContainer, args.Dpi);

            var workingDirectory = @"c:\temp";
            fileName = Path.Combine(workingDirectory, $"dwg_{Guid.NewGuid()}.png");

            render.Render(mainContainer);
            encoder.Frames.Add(BitmapFrame.Create(render));
            using (var s = File.Open(fileName, FileMode.Create))
            {
                encoder.Save(s);
            }
        }
开发者ID:denny-hendrix,项目名称:SyteLine-Tech-Drawing,代码行数:22,代码来源:ImageRenderer.cs

示例5: AutoCol_MinWidth

		public void AutoCol_MinWidth ()
		{
			var grid = new Grid ();
			grid.AddColumns(Auto, Star);
			grid.ColumnDefinitions[0].MinWidth = 10;
			grid.AddChild(ContentControlWithChild(), 0, 0, 0, 0);

			CreateAsyncTest(grid, () => {
				grid.UpdateLayout();
				Assert.AreEqual(50, grid.ColumnDefinitions[0].ActualWidth, "#1");
			});
		}
开发者ID:dfr0,项目名称:moon,代码行数:12,代码来源:GridTestAuto.cs

示例6: AutoCol_Empty_MinWidth

		public void AutoCol_Empty_MinWidth ()
		{
			// Ensure MinWidth is respected in an empty Auto segment
			var grid = new Grid();
			grid.AddColumns(Auto, Star);
			grid.ColumnDefinitions[0].MinWidth = 10;
			grid.AddChild(ContentControlWithChild(), 0, 1, 0, 0);

			CreateAsyncTest(grid, () => {
				grid.UpdateLayout();
				Assert.AreEqual(10, grid.ColumnDefinitions[0].ActualWidth, "#1");
			});
		}
开发者ID:dfr0,项目名称:moon,代码行数:13,代码来源:GridTestAuto.cs

示例7: OnContentNameChanged

        private void OnContentNameChanged(DependencyObject content, string oldName, string newName)
        {
            ContentPresenter oldPresenter = GetPresenter(oldName);
            if (oldPresenter != null) {
                oldPresenter.Content = null;
            }

            ContentPresenter newPresenter = GetPresenter(newName);
            if (newPresenter != null) {
                Grid grid = new Grid();
                grid.Children.Add((UIElement)content);

                newPresenter.Content = grid;
                grid.UpdateLayout();
            }
        }
开发者ID:nikhilk,项目名称:silverlightfx,代码行数:16,代码来源:TemplatePanel.cs

示例8: OnContentListCollectionChanged

        private void OnContentListCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add) {
                UIElement content = (UIElement)e.NewItems[0];

                TemplatePanel currentOwner = TemplatePanel.GetContainer(content);
                if (currentOwner != null) {
                    currentOwner.ContentList.Remove(content);
                }

                TemplatePanel.SetContainer(content, this);

                string contentName = TemplatePanel.GetContentName(content);

                ContentPresenter contentPresenter = GetPresenter(contentName);
                if (contentPresenter != null) {
                    Grid grid = new Grid();
                    grid.Children.Add(content);

                    contentPresenter.Content = grid;
                    grid.UpdateLayout();
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove) {
                UIElement content = (UIElement)e.OldItems[0];

                string contentName = TemplatePanel.GetContentName(content);

                ContentPresenter contentPresenter = GetPresenter(contentName);
                if (contentPresenter != null) {
                    contentPresenter.Content = null;
                }
            }
        }
开发者ID:nikhilk,项目名称:silverlightfx,代码行数:34,代码来源:TemplatePanel.cs

示例9: OnApplyTemplate

        /// <internalonly />
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_contentList.Count != 0) {
                Dispatcher.BeginInvoke(delegate() {
                    foreach (UIElement content in _contentList) {
                        string contentName = TemplatePanel.GetContentName(content);
                        ContentPresenter contentPresenter = GetPresenter(contentName);

                        if (contentPresenter != null) {
                            Grid grid = new Grid();
                            grid.Children.Add(content);

                            contentPresenter.Content = grid;
                            grid.UpdateLayout();
                        }
                    }
                });
            }
        }
开发者ID:nikhilk,项目名称:silverlightfx,代码行数:22,代码来源:TemplatePanel.cs

示例10: ExecuteThread

        public string ExecuteThread(FileItem item,string infile, string dest, ValuePairEnumerator configData)
        {
            try
            {

            var conf = new OverlayTransformViewModel(configData);
            using (var fileStream = new MemoryStream(File.ReadAllBytes(infile)))
            {
                BitmapDecoder bmpDec = BitmapDecoder.Create(fileStream,
                    BitmapCreateOptions.PreservePixelFormat,
                    BitmapCacheOption.OnLoad);
                WriteableBitmap writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames[0]);
                writeableBitmap.Freeze();

                Grid grid = new Grid
                {
                    Width = writeableBitmap.PixelWidth,
                    Height = writeableBitmap.PixelHeight,
                    ClipToBounds = true,
                    SnapsToDevicePixels = true
                };
                grid.UpdateLayout();
                var size = new Size(writeableBitmap.PixelWidth, writeableBitmap.PixelWidth);
                grid.Measure(size);
                grid.Arrange(new Rect(size));

                Image overlay = new Image();
                Image image = new Image { Width = writeableBitmap.PixelWidth, Height = writeableBitmap.PixelHeight };
                image.BeginInit();
                image.Source = writeableBitmap;
                image.EndInit();
                image.Stretch = Stretch.Fill;
                grid.Children.Add(image);
                grid.UpdateLayout();

                string text = "";
                if (!string.IsNullOrEmpty(conf.Text))
                {
                    Regex regPattern = new Regex(@"\[(.*?)\]", RegexOptions.Singleline);
                    MatchCollection matchX = regPattern.Matches(conf.Text);
                    text = matchX.Cast<Match>()
                        .Aggregate(conf.Text,
                            (current1, match) =>
                                item.FileNameTemplates.Where(
                                    template =>
                                        String.Compare(template.Name, match.Value,
                                            StringComparison.InvariantCultureIgnoreCase) == 0).Aggregate(current1,
                                                (current, template) => current.Replace(match.Value, template.Value)));
                }
                TextBlock textBlock = new TextBlock
                {
                    Text = text,
                    Foreground = (SolidColorBrush) new BrushConverter().ConvertFromString(conf.FontColor),
                    FontFamily = (FontFamily) new FontFamilyConverter().ConvertFromString(conf.Font),
                    FontSize = conf.FontSize,
                    Opacity = conf.Transparency/100.00
                };
                if (conf.A11)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                    textBlock.VerticalAlignment = VerticalAlignment.Top;
                }
                if (conf.A12)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                    textBlock.VerticalAlignment = VerticalAlignment.Top;
                }
                if (conf.A13)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlock.VerticalAlignment = VerticalAlignment.Top;
                }
                if (conf.A21)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                }
                if (conf.A22)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                }
                if (conf.A23)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                }
                if (conf.A31)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                    textBlock.VerticalAlignment = VerticalAlignment.Bottom;
                }
                if (conf.A32)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                    textBlock.VerticalAlignment = VerticalAlignment.Bottom;
                }
                if (conf.A33)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
//.........这里部分代码省略.........
开发者ID:show027,项目名称:digiCamControl,代码行数:101,代码来源:OverlayTransform.cs

示例11: ConstructPage

        /// <summary>
        /// This method constructs the document page (visual) to print
        /// </summary>
        private DocumentPage ConstructPage(Grid content, int pageNumber)
        {
            if (content == null)
                return null;

            //Build the page inc header and footer
            Grid pageGrid = new Grid();

            //Header row
            AddGridRow(pageGrid, GridLength.Auto);

            //Content row
            AddGridRow(pageGrid, new GridLength(1.0d, GridUnitType.Star));

            //Footer row
            AddGridRow(pageGrid, GridLength.Auto);

            ContentControl pageHeader = new ContentControl();
            pageHeader.Content = this.CreateDocumentHeader();
            pageGrid.Children.Add(pageHeader);

            if (content != null)
            {
                content.SetValue(Grid.RowProperty, 1);
                pageGrid.Children.Add(content);
            }

            ContentControl pageFooter = new ContentControl();
            pageFooter.Content = CreateDocumentFooter(pageNumber + 1);
            pageFooter.SetValue(Grid.RowProperty, 2);

            pageGrid.Children.Add(pageFooter);

            double width = this.PageSize.Width - (this.PageMargin.Left + this.PageMargin.Right);
            double height = this.PageSize.Height - (this.PageMargin.Top + this.PageMargin.Bottom);
            
            Border border = CreateBorder();
            border.Measure(new Size(this.PageSize.Width, this.PageSize.Width));
            border.Arrange(new Rect(this.PageMargin.Left, this.PageMargin.Top, width, height));
            border.UpdateLayout();

            pageGrid.Measure(new Size(width*0.98 , height*0.98));
            pageGrid.Arrange(new Rect(this.PageMargin.Left, this.PageMargin.Top, width * 0.98, height * 0.98));

            pageGrid.UpdateLayout();
             border.Child = pageGrid;
            border.UpdateLayout();

            return new DocumentPage(border);
        }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:53,代码来源:CustomDataGridDocumentPaginator.cs

示例12: initialChildren

        // Calculated content height
        protected virtual void initialChildren()
        {
            double w = System.Windows.Application.Current.Host.Content.ActualWidth;

            topShadow = GetTemplateChild("TopShadow") as Rectangle;
            bottomShadow = GetTemplateChild("BottomShadow") as Rectangle;
            contentView = GetTemplateChild("ContentView") as Grid;
            buttonContainer = GetTemplateChild("ButtonContainer") as StackPanel;
            curtain = GetTemplateChild("Curtain") as Rectangle;

            // Add an optional title label
            titleLabel = null;
            if (title != null)
            {
                titleLabel = new TextBlock();
                titleLabel.Text = title;
                titleLabel.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xd9, 0xf3));
                titleLabel.FontSize = 42;
                titleLabel.HorizontalAlignment = HorizontalAlignment.Center;
                titleLabel.TextWrapping = TextWrapping.Wrap;
                titleLabel.TextAlignment = TextAlignment.Center;
                titleLabel.Margin = new Thickness(0, 8, 0, 8);
                titleLabel.SetValue(Grid.RowProperty, 0);
                contentView.Children.Add(titleLabel);
            }

            // Add any custom content
            if (contentElement != null)
            {
                contentElement.SetValue(Grid.RowProperty, 1);
                contentView.Children.Add(contentElement);
                contentView.InvalidateArrange();
                contentView.UpdateLayout();

                double measuredWidth = contentElement.ActualWidth + contentElement.Margin.Left + contentElement.Margin.Right;
                double measuredHeight = 0;
                if (titleLabel != null)
                {
                    measuredHeight += titleLabel.ActualHeight;
                }

                double contentHeight = Math.Max(contentElement.ActualHeight, contentElement.Height);
                if(!double.IsNaN(contentHeight))
                    measuredHeight += contentHeight + contentElement.Margin.Top + contentElement.Margin.Bottom;
                else
                    measuredHeight += 240 + contentElement.Margin.Top + contentElement.Margin.Bottom;

                expectedContentSize = new Size(measuredWidth, measuredHeight);
            }
            else
            {
                expectedContentSize = new Size(w, 240);
            }

            // Add custom buttons
            if (buttonTitles.Count > 0)
            {
                foreach (string buttonTitle in buttonTitles)
                {
                    var button = new Avarice.Controls.Button();
                    button.Content = buttonTitle;
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }
            }
            else if(Buttons.Count > 0)
            {
                foreach (var button in Buttons)
                {
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }

            }
        }
开发者ID:powerytg,项目名称:indulged-flickr,代码行数:80,代码来源:ModalPopup.cs

示例13: expandFeaturesPermissions_Tap

        private void expandFeaturesPermissions_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            int row = -1;
            Grid gridContainer = new Grid();
            if ((sender as ExpanderView).Name == "expanderFeatures")
            {
                gridContainer = expanderFeatures.Parent as Grid;
                row = 1;
            }
            else
                if ((sender as ExpanderView).Name == "expanderPermissions")
                {
                    gridContainer = expanderPermissions.Parent as Grid;
                    row = 2;
                }

            var height = gridContainer.RowDefinitions[row].Height;
            if (height == new GridLength(40))
                gridContainer.RowDefinitions[row].Height = new GridLength();
            else
                gridContainer.RowDefinitions[row].Height = new GridLength(40);

            gridContainer.UpdateLayout();
        }
开发者ID:agzagrean,项目名称:LunaAppWP8,代码行数:24,代码来源:MainPage.xaml.cs

示例14: WriteTileToDisk

        protected static string WriteTileToDisk(string year, string description, int width, int height, string fontSize, Thickness margins)
        {
            Grid container = new Grid()
            {
                Width = width,
                Height = height,
                Background = (Brush)Application.Current.Resources["TransparentBrush"]
            };

            container.Children.Add(GetTextBlockToRender(description, fontSize, margins));

            // Force the container to render itself
            container.UpdateLayout();
            container.Arrange(new Rect(0, 0, width, height));

            var writeableBitmap = new WriteableBitmap(container, null);

            string fileName = SharedImagePath + "tile" + height + width + ".png";
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = new IsolatedStorageFileStream(fileName, FileMode.Create, storage))
                {
                    if (writeableBitmap.PixelHeight > 0)
                    {
                        writeableBitmap.WritePNG(stream);
                    }
                }
            }

            return fileName;
        }
开发者ID:camradal,项目名称:TodayILearned,代码行数:31,代码来源:LiveTile.cs

示例15: CreateBasicPageParameter

		void CreateBasicPageParameter ()
			{
			BrushConverter BRConverter = new BrushConverter ();
			GridLengthConverter GLConverter = new GridLengthConverter ();
			m_GlobalGrid_2 = new Grid ();
			m_GlobalGrid_2.Visibility = Visibility.Visible;
			this.Content = m_GlobalGrid_2;
			m_GlobalGrid_2.IsEnabled = true;
			ColumnDefinition GlobalGrid_2_Column = new ColumnDefinition ();
			m_GlobalGrid_2.ColumnDefinitions.Add (GlobalGrid_2_Column);
			RowDefinition GlobalGrid_2_NameRow = new RowDefinition ();
			GlobalGrid_2_NameRow.Height = (GridLength)GLConverter.ConvertFromString ("10*");
			RowDefinition GlobalGrid_2_Filler_1 = new RowDefinition ();
			GlobalGrid_2_Filler_1.Height = (GridLength)GLConverter.ConvertFromString ("*");
			RowDefinition GlobalGrid_2_PictureRow = new RowDefinition ();
			GlobalGrid_2_PictureRow.Height = (GridLength)GLConverter.ConvertFromString ("80*");
			RowDefinition GlobalGrid_2_Filler_2 = new RowDefinition ();
			GlobalGrid_2_Filler_2.Height = (GridLength)GLConverter.ConvertFromString ("*");
			RowDefinition GlobalGrid_2_InfoRow = new RowDefinition ();
			GlobalGrid_2_InfoRow.Height = (GridLength)GLConverter.ConvertFromString ("10*");
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_NameRow);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_Filler_1);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_PictureRow);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_Filler_2);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_InfoRow);

			m_Name_2_Canvas = new Canvas ();
			m_Name_2_Canvas.Visibility = Visibility.Visible;
			m_GlobalGrid_2.Children.Add (m_Name_2_Canvas);
			Grid.SetColumn (m_Name_2_Canvas, 0);
			Grid.SetRow (m_Name_2_Canvas, 0);

			m_Picture_2_Canvas = new Canvas ();
			m_Picture_2_Canvas.Visibility = Visibility.Visible;
			m_GlobalGrid_2.Children.Add (m_Picture_2_Canvas);
			Grid.SetColumn (m_Picture_2_Canvas, 0);
			Grid.SetRow (m_Picture_2_Canvas, 2);
			NameScope.SetNameScope (m_GlobalGrid_2, new NameScope ());
			m_Picture_2_Canvas.Background = (Brush)BRConverter.ConvertFromString (WeatherDetailBackGroundColor);

			m_Info_2_Canvas = new Canvas ();
			m_Info_2_Canvas.Visibility = Visibility.Visible;
			m_GlobalGrid_2.Children.Add (m_Info_2_Canvas);
			Grid.SetColumn (m_Info_2_Canvas, 0);
			Grid.SetRow (m_Info_2_Canvas, 4);
			m_Info_2_Canvas.Background = (Brush)BRConverter.ConvertFromString (WeatherHeadlineBackGroundColor);

			m_GlobalGrid_2.UpdateLayout ();
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:49,代码来源:WPMediaRunWeatherDisplayControl.xaml.cs


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