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


C# Controls.Grid类代码示例

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


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

示例1: init

        void init()
        {
            Width = DeviceWidth;
            Height = DeviceHeight;
            _actualheight = DeviceHeight;

            _contentpanel = new StackPanel() { Orientation = Orientation.Vertical };
            _contentpanel.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
            _contentpanel.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            _contentpanel.RenderTransform = new CompositeTransform() { TranslateX = 320 };
            _contentpanel.SizeChanged += _contentpanel_SizeChanged;
            _contentpanel.Width = 586.0;
            
            Children.Add(_contentpanel);

            Grid header = new Grid() { Width = 100.0, Height = 214.0 };
            Grid footer = new Grid() { Width = 100.0, Height = 214.0 };
            Grid separation = new Grid() { Width = 100.0, Height = 66.0 };
            _titleblock = new TextBlock() { TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap, FontSize = 56 };
            _titleblock.LayoutUpdated += _titleblock_LayoutUpdated;

            _itemspanel = new StackPanel() { Orientation = Orientation.Vertical };
            _itemspanel.LayoutUpdated += _itemspanel_LayoutUpdated;
            _itemspanel.Width = 560.0;

            //childrens of content
            _contentpanel.Children.Add(header);
            _contentpanel.Children.Add(_titleblock);
            _contentpanel.Children.Add(separation);
            _contentpanel.Children.Add(_itemspanel);
            _contentpanel.Children.Add(footer);
        }
开发者ID:Milton761,项目名称:mLearningCoreEN,代码行数:32,代码来源:ItemizeTextElement.cs

示例2: GenerateChartStructure

        private void GenerateChartStructure()
        {
            // Main grid
            Grid root = new Grid { Margin = new Thickness(0, 10, 0, 10) }; // Vertical Margin for labels
            root.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0, GridUnitType.Auto) }); // Column for labels
            root.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // Column for chart
            RootElement.Children.Add(root);

            // Grid for labels (column 0)
            _labels = new Grid();
            root.Children.Add(_labels);

            // Grid for chart (column 1)
            Grid chart = new Grid();
            Grid.SetColumn(chart, 1);
            root.Children.Add(chart);

            // Axis
            Border axisY = new Border
                           	{
                                BorderThickness = new Thickness(0.75),
                                BorderBrush = ForegroundColor,
                           		Opacity = 0.5,
                           		HorizontalAlignment = HorizontalAlignment.Left,
                           		VerticalAlignment = VerticalAlignment.Stretch,
                           		Margin = new Thickness(0, -5, 0, -5)
                            };
            chart.Children.Add(axisY);

            // Grid for series of points
            _series = new Grid();
            chart.Children.Add(_series);
        }
开发者ID:smarteatsmarties,项目名称:arcgis-portalviewer-dotnet,代码行数:33,代码来源:ColumnChart.cs

示例3: OnApplyTemplate

		protected override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			canvas = (Grid)GetTemplateChild("canvas");
			UpdateSource();
		}
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:7,代码来源:FadingImage.cs

示例4: InitializeComponent

        public void InitializeComponent()
        {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-appx:///Tweet.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);
 
            pageRoot = (Mu_genotype1.Common.LayoutAwarePage)this.FindName("pageRoot");
            primaryColumn = (Windows.UI.Xaml.Controls.ColumnDefinition)this.FindName("primaryColumn");
            titlePanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("titlePanel");
            itemListScrollViewer = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("itemListScrollViewer");
            itemListScrollViewer2 = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("itemListScrollViewer2");
            PeerTweets = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("PeerTweets");
            itemListView2 = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView2");
            TweetBox = (Windows.UI.Xaml.Controls.TextBox)this.FindName("TweetBox");
            TweetIt = (Windows.UI.Xaml.Controls.Button)this.FindName("TweetIt");
            PinPanel = (Windows.UI.Xaml.Controls.StackPanel)this.FindName("PinPanel");
            itemListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("itemListView");
            PinTb = (Windows.UI.Xaml.Controls.TextBox)this.FindName("PinTb");
            VerifyPinButton = (Windows.UI.Xaml.Controls.Button)this.FindName("VerifyPinButton");
            backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton");
            pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle");
            pageSubtitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageSubtitle");
            FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape");
            Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled");
            FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait");
            FullScreenPortrait_Detail = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait_Detail");
            Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
            Snapped_Detail = (Windows.UI.Xaml.VisualState)this.FindName("Snapped_Detail");
            TwitterConnectBtn = (Windows.UI.Xaml.Controls.Button)this.FindName("TwitterConnectBtn");
            RefreshButton = (Windows.UI.Xaml.Controls.Button)this.FindName("RefreshButton");
        }
开发者ID:sagar-sm,项目名称:Mu,代码行数:33,代码来源:Tweet.g.i.cs

示例5: AddExample

        private void AddExample(IpaSymbol ipaSymbol)
        {
            TextBlock letterBlock = new TextBlock();
            letterBlock.Style = this.Resources["LetterStyle"] as Style;
            letterBlock.Text = ipaSymbol.Value;

            TextBlock exampleBlock = new TextBlock();
            exampleBlock.Style = this.Resources["ExampleStyle"] as Style;
            IpaSymbol.SetExampleBlock(exampleBlock);

            StackPanel stackPanel = new StackPanel();
            stackPanel.VerticalAlignment = VerticalAlignment.Center;
            stackPanel.Children.Add(letterBlock);
            stackPanel.Children.Add(exampleBlock);

            Grid grid = new Grid();
            grid.Background = ipaSymbol.BackgroundBrush;
            grid.Height = Window.Current.Bounds.Height;
            grid.Children.Add(stackPanel);

            WordsPanel.Children.Add(grid);
            WordsPanel.InvalidateArrange();
            Debug.WriteLine(grid.ActualHeight);
            //Debug.WriteLine(WordsPanel.Children.Count);
        }
开发者ID:kiewic,项目名称:WindowsStoreApps,代码行数:25,代码来源:MainPage.xaml.cs

示例6: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                KinectRegion kinectRegion = new KinectRegion();
                Grid grid = new Grid();
                KinectUserViewer userViewer = new KinectUserViewer()

                {
                    Height = 100,
                    Width = 121,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Top,

                };
                grid.Children.Add(kinectRegion);
                grid.Children.Add(userViewer);
                kinectRegion.Content = rootFrame;




                // Place the frame in the current Window
                Window.Current.Content = grid;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
开发者ID:mhnd89,项目名称:Knowledge-playgroundv1,代码行数:65,代码来源:App.xaml.cs

示例7: OnApplyTemplate

        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding
        /// layout pass) call <see cref="OnApplyTemplate"/>. In simplest terms, this means the method
        /// is called just before a UI element displays in an application. Override this
        /// method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            contentGrid = this.GetTemplateChild(PART_CONTENT_GRID) as Grid;
            commandContainer = this.GetTemplateChild(PART_COMMAND_CONTAINER) as Grid;
            leftCommandPanel = this.GetTemplateChild(PART_LEFT_COMMAND_PANEL) as StackPanel;
            rightCommandPanel = this.GetTemplateChild(PART_RIGHT_COMMAND_PANEL) as StackPanel;

            transform = contentGrid.RenderTransform as CompositeTransform;

            leftCommandTransform = leftCommandPanel.RenderTransform as CompositeTransform;
            rightCommandTransform = rightCommandPanel.RenderTransform as CompositeTransform;

            contentGrid.ManipulationDelta += ContentGrid_ManipulationDelta;
            contentGrid.ManipulationCompleted += ContentGrid_ManipulationCompleted;

            contentAnimation = new DoubleAnimation();
            Storyboard.SetTarget(contentAnimation, transform);
            Storyboard.SetTargetProperty(contentAnimation, "TranslateX");
            contentAnimation.To = 0;
            contentAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(100));

            contentStoryboard = new Storyboard();
            contentStoryboard.Children.Add(contentAnimation);

            commandContainer.Background = LeftBackground as SolidColorBrush;

            base.OnApplyTemplate();
        }
开发者ID:KooKiz,项目名称:comet,代码行数:34,代码来源:SlidableListItem.cs

示例8: CreateControl

        private void CreateControl()
        {
            var grid = new Grid();

            var margin = new Thickness {Top = 24};

            grid.Margin = margin;

            var distinctEdgesCheckBox = new CheckBox {Margin = margin, VerticalAlignment = VerticalAlignment.Center};

            var padding = new Thickness {Left = 12, Right = 12};
            distinctEdgesCheckBox.Padding = padding;

            var textBlock = new TextBlock
            {
                VerticalAlignment = VerticalAlignment.Center,
                FontSize = FilterControlTitleFontSize,
                Text = _resourceLoader.GetString("DistinctEdges/Text")
            };

            distinctEdgesCheckBox.Content = textBlock;
            distinctEdgesCheckBox.IsChecked = Filter.DistinctEdges;
            distinctEdgesCheckBox.Checked += distinctEdgesCheckBox_Checked;
            distinctEdgesCheckBox.Unchecked += distinctEdgesCheckBox_Unchecked;

            var rowDefinition = new RowDefinition {Height = GridLength.Auto};
            grid.RowDefinitions.Add(rowDefinition);

            var columnDefinition = new ColumnDefinition {Width = GridLength.Auto};
            grid.ColumnDefinitions.Add(columnDefinition);

            grid.Children.Add(distinctEdgesCheckBox);

            Control = grid;
        }
开发者ID:JuannyWang,项目名称:filter-effects,代码行数:35,代码来源:MarvelFilter.cs

示例9: OnApplyTemplate

		protected override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			Body = GetTemplateChild(BodyName) as Grid;

			_horizontalSlider = GetTemplateChild(HorizontalSliderName) as SuperSlider;
			_verticalSlider = GetTemplateChild(VerticalSliderName) as SuperSlider;

			_horizontalSelectedColor = GetTemplateChild(HorizontalSelectedColorName) as Rectangle;
			_verticalSelectedColor = GetTemplateChild(VerticalSelectedColorName) as Rectangle;

			if (_horizontalSlider != null)
				_horizontalSlider.ApplyTemplate();

			if (_verticalSlider != null)
				_verticalSlider.ApplyTemplate();

			if (Color.A == 0 && Color.R == 0 && Color.G == 0 && Color.B == 0)
				Color = Windows.UI.Color.FromArgb(255, 6, 255, 0); // this should be theme accent brush I think.
			else
				UpdateLayoutBasedOnColor();

			if (Thumb == null)
				Thumb = new ColorSliderThumb();

			IsEnabledVisualStateUpdate();
		}
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:28,代码来源:ColorSlider2.cs

示例10: InitializeComponent

        public void InitializeComponent()
        {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-appx:///SearchResultsPage1.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);
 
            pageRoot = (Fashionizer2.Common.LayoutAwarePage)this.FindName("pageRoot");
            resultsViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("resultsViewSource");
            filtersViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("filtersViewSource");
            resultsPanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("resultsPanel");
            noResultsTextBlock = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("noResultsTextBlock");
            typicalPanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("typicalPanel");
            snappedPanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("snappedPanel");
            resultsListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("resultsListView");
            filtersItemsControl = (Windows.UI.Xaml.Controls.ItemsControl)this.FindName("filtersItemsControl");
            resultsGridView = (Windows.UI.Xaml.Controls.GridView)this.FindName("resultsGridView");
            backButton = (Windows.UI.Xaml.Controls.Button)this.FindName("backButton");
            pageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("pageTitle");
            resultText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("resultText");
            queryText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("queryText");
            ApplicationViewStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ApplicationViewStates");
            ResultStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("ResultStates");
            ResultsFound = (Windows.UI.Xaml.VisualState)this.FindName("ResultsFound");
            NoResultsFound = (Windows.UI.Xaml.VisualState)this.FindName("NoResultsFound");
            FullScreenLandscape = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenLandscape");
            Filled = (Windows.UI.Xaml.VisualState)this.FindName("Filled");
            FullScreenPortrait = (Windows.UI.Xaml.VisualState)this.FindName("FullScreenPortrait");
            Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
        }
开发者ID:BCNWIN8HATFashion,项目名称:Fashionizer,代码行数:31,代码来源:SearchResultsPage1.g.i.cs

示例11: InitializeComponent

        public void InitializeComponent()
        {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
            Application.LoadComponent(this, new System.Uri("ms-resource://spotifyapp/Files/View/CollectionSummaryPage.xaml"));

            CollectionViewSource = (Windows.UI.Xaml.Data.CollectionViewSource)this.FindName("CollectionViewSource");
            LayoutRoot = (Windows.UI.Xaml.Controls.Grid)this.FindName("LayoutRoot");
            OrientationStates = (Windows.UI.Xaml.VisualStateGroup)this.FindName("OrientationStates");
            Full = (Windows.UI.Xaml.VisualState)this.FindName("Full");
            Fill = (Windows.UI.Xaml.VisualState)this.FindName("Fill");
            Portrait = (Windows.UI.Xaml.VisualState)this.FindName("Portrait");
            Snapped = (Windows.UI.Xaml.VisualState)this.FindName("Snapped");
            ScrollViewer = (Windows.UI.Xaml.Controls.ScrollViewer)this.FindName("ScrollViewer");
            CategoryPanel = (Windows.UI.Xaml.Controls.StackPanel)this.FindName("CategoryPanel");
            HeaderTitlePanel = (Windows.UI.Xaml.Controls.Grid)this.FindName("HeaderTitlePanel");
            ItemGridView = (Windows.UI.Xaml.Controls.GridView)this.FindName("ItemGridView");
            ItemListView = (Windows.UI.Xaml.Controls.ListView)this.FindName("ItemListView");
            Title = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("Title");
            Image = (Windows.UI.Xaml.Controls.Image)this.FindName("Image");
            DescriptionText = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("DescriptionText");
            BackButton = (Windows.UI.Xaml.Controls.Button)this.FindName("BackButton");
            PageTitle = (Windows.UI.Xaml.Controls.TextBlock)this.FindName("PageTitle");
        }
开发者ID:beaugunderson,项目名称:Spotify-Metro-Style-App,代码行数:26,代码来源:CollectionSummaryPage.g.i.cs

示例12: OnApplyTemplate

 protected override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _rootGrid = GetTemplateChild("RootGrid") as Grid;
     _contentGrid = GetTemplateChild("ContentGrid") as Grid;
     if(_layout==LayoutEnum.Stretch)
     {
         _contentGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
         _contentGrid.VerticalAlignment = VerticalAlignment.Stretch;
     }
     else if(_layout==LayoutEnum.Bottom)
     {
         _contentGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
         _contentGrid.VerticalAlignment = VerticalAlignment.Bottom;
     }
     _contentGrid.Children.Add(_rootFramework);
     _inStory = _rootGrid.Resources["InStory"] as Storyboard;
     _outStory = _rootGrid.Resources["OutStory"] as Storyboard;
     _maskBorder = GetTemplateChild("MaskBorder") as Border;
     _outStory.Completed += ((sender,e)=>
     {
         _currentPopup.IsOpen = false;
     });
     _maskBorder.Tapped += ((sendert, et) =>
     {
         if (!_isOpen)
         {
             return;
         }
         Hide();
     });
     _tcs.TrySetResult(0);
 }
开发者ID:JuniperPhoton,项目名称:JP.Utils.UWP,代码行数:33,代码来源:ContentPopupEx.cs

示例13: OnApplyTemplate

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // make sure we listen at the right time to add/remove the back button event handlers
            if(_backButton != null)
            {
                _backButton.Tapped -= OnBackButtonTapped;
            }
            _backButton = GetTemplateChild("SettingsBackButton") as Button;
            if(_backButton != null)
            {
                _backButton.Tapped += OnBackButtonTapped;
            }

            // need to get these grids in order to set the offsets correctly in RTL situations
            if (_contentGrid == null)
            {
                _contentGrid = GetTemplateChild("SettingsFlyoutContentGrid") as Grid;
            }
            _contentGrid.Transitions = new TransitionCollection();
            _contentGrid.Transitions.Add(new EntranceThemeTransition()
            {
                FromHorizontalOffset = CONTENT_HORIZONTAL_OFFSET // TODO: if left edge need to multiply by -1
            });
        }
开发者ID:WillemGijsbers,项目名称:callisto,代码行数:26,代码来源:SettingsFlyout.cs

示例14: Convert

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var layers = (IList<PageLayer>)value;
            var grd = new Grid();
            foreach (var layer in layers.Where(x=>x.IsEnabled)) {
                
                var xaml = "";
                foreach (var xamlFragment in layer.XamlFragments.Where(x=>x.IsEnabled)) {
                    xaml += xamlFragment.Xaml;
                }

                var nsXaml = string.Empty;
                if (layer.HasChildContainerCanvas) nsXaml = $"<Canvas>{xaml}</Canvas>";
                else nsXaml = xaml;

                var nsTemplate = $"<Grid xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" HorizontalAlignment=\"Stretch\" xmlns:xuip=\"using:X.UI.Path\" xmlns:lc=\"using:X.Viewer.SketchFlow.Controls\" xmlns:lcs=\"using:X.Viewer.SketchFlow.Controls.Stamps\" VerticalAlignment=\"Stretch\" >{nsXaml}</Grid>";
                //todo: create then inject the converter "ExtensionToImageSourceConverter"  <-- after much fucking around i added it to apps root resource dict ... wont work if injected in..

                if (xaml.Length > 0) { 
                    var xamlFe = (FrameworkElement)XamlReader.Load(UnescapeString(nsTemplate));
                    grd.Children.Add(xamlFe);
                }
            }

            if (grd.Children.Count > 0) return grd;

            return null;
        }
开发者ID:liquidboy,项目名称:X,代码行数:28,代码来源:XamlFragmentsToContentConverter.cs

示例15: OnApplyTemplate

 protected override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     textBlockStatus = GetTemplateChild("textBlockStatus") as TextBlock;
     LayoutRoot = GetTemplateChild("LayoutRoot") as Grid;
     InitializeProgressType();
 }
开发者ID:x01673,项目名称:dreaming,代码行数:7,代码来源:NotifyControl.cs


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