本文整理匯總了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);
}
示例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);
}
示例3: OnApplyTemplate
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
canvas = (Grid)GetTemplateChild("canvas");
UpdateSource();
}
示例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");
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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");
}
示例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");
}
示例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);
}
示例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
});
}
示例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;
}
示例15: OnApplyTemplate
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
textBlockStatus = GetTemplateChild("textBlockStatus") as TextBlock;
LayoutRoot = GetTemplateChild("LayoutRoot") as Grid;
InitializeProgressType();
}