本文整理汇总了C#中System.Windows.Controls.Grid类的典型用法代码示例。如果您正苦于以下问题:C# Grid类的具体用法?C# Grid怎么用?C# Grid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Grid类属于System.Windows.Controls命名空间,在下文中一共展示了Grid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
Body = GetTemplateChild(BodyName) as Grid;
Slider = GetTemplateChild(SliderName) as SuperSlider;
if (Thumb == null)
Thumb = new ColorSliderThumb();
SelectedColor = GetTemplateChild(SelectedColorName) as Rectangle;
SizeChanged += UserControl_SizeChanged;
if (Slider != null)
{
Slider.ValueChanged += Slider_ValueChanged;
if (Color.A == 0 && Color.R == 0 && Color.G == 0 && Color.B == 0)
Color = System.Windows.Media.Color.FromArgb(255, 6, 255, 0);
else
UpdateLayoutBasedOnColor();
}
IsEnabledVisualStateUpdate();
}
示例2: Evaluate
// ReSharper restore UnassignedField.Global
// ReSharper restore MemberCanBePrivate.Global
public void Evaluate(int SpreadMax)
{
UIElementOut.SliceCount = 1;
if (UIElementOut == null || !(UIElementOut[0] is Grid))
UIElementOut[0] = new Grid();
var toRemove = new List<UIElement>();
((Grid) UIElementOut[0]).Children.Cast<UIElement>().ToList().ForEach(element =>
{
if (!_elementInputs.Where(input => input.IOObject[0] != null).Any(input => input.IOObject[0].Equals(element)))
toRemove.Add(element);
});
toRemove.ForEach(element => ((Grid) UIElementOut[0]).Children.Remove(element));
for (var i = 0; i < _elementInputs.SliceCount; i++)
{
//if (_elementInputs[i].IOObject[0] == null && ((Grid) UIElementOut[0]).Children[i] != null)
// ((Grid) UIElementOut[0]).Children.RemoveAt(i);
if (_elementInputs[i].IOObject[0] != null && !(((Grid) UIElementOut[0]).Children.Contains(_elementInputs[i].IOObject[0])))
((Grid) UIElementOut[0]).Children.Add(_elementInputs[i].IOObject[0]);
}
}
示例3: CreateTabItem
public static TabItem CreateTabItem(WrapPanel headerPanel, Grid textBoxGrid)
{
TabItem tabItem = new TabItem();
tabItem.Header = headerPanel;
tabItem.Content = textBoxGrid;
return tabItem;
}
示例4: MainTab
public MainTab(int page, TabItem newTab, Image newVerso, Image newRecto, Grid canvas, Grid vGrid, Grid rGrid, Button delBtn, ScatterView SV, ScatterViewItem si, Grid vSwipeGrid, Grid rSwipeGrid, Grid vTranslationGrid, Grid rTranslationGrid, Grid vBoxesGrid, Grid rBoxesGrid, TextBlock headerText, SurfaceWindow1.language language)
{
_page = page;
_tab = newTab;
_verso = newVerso;
_recto = newRecto;
_canvas = canvas;
_vGrid = vGrid;
_rGrid = rGrid;
_SVI = si;
_delButton = delBtn;
numFingersRecto = 0;
numFingersVerso = 0;
fingerPos = new List<Point>();
avgTouchPoint = new Point(-1, 0);
_vSwipeGrid = vSwipeGrid;
_rSwipeGrid = rSwipeGrid;
_vTranslationGrid = vTranslationGrid;
_rTranslationGrid = rTranslationGrid;
_vBoxesGrid = vBoxesGrid;
_rBoxesGrid = rBoxesGrid;
_twoPage = true;
_SV = SV;
_headerTB = headerText;
_currentLanguage = language;
_previousLanguage = _currentLanguage;
_worker = new Workers(this);
}
示例5: QryptoWirePage
protected QryptoWirePage()
{
Loaded += (sender, args) =>
{
SystemTray.IsVisible = false;
var dc = DataContext as QryptoViewModel;
if (dc != null)
{
var pageContent = Content as FrameworkElement;
if(pageContent == null)
return;
var rootGrid = new Grid
{
RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }
};
var overlay = new WorkingOverlay();
Grid.SetRow(overlay, 1);
Grid.SetRow(pageContent, 1);
Content = rootGrid;
rootGrid.Children.Add(pageContent);
rootGrid.Children.Add(overlay);
}
};
}
示例6: ListView_MouseDoubleClick
private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
//InstrumentHierarchyViewModel item = sender as InstrumentHierarchyViewModel;
ExploreHirachyInstrumentVMWrapper item = ExplorerListView_.SelectedItem as ExploreHirachyInstrumentVMWrapper;
if (item != null)
{
LayoutDocument layoutDoc = new LayoutDocument();
//int count = this.Parent.ChildrenCount;
//LayoutDocumentPane pane = new LayoutDocumentPane();
Grid grid = new Grid();
grid.Children.Add(item.view());
layoutDoc.Content = grid;
layoutDoc.Title = item.ProductName_;
mainWindow_.DocumentPane_.Children.Add(layoutDoc);
OutputLogViewModel.addResult(new MessageOutput(item.ProductName_ + " is loaded"));
}
//MainWindow.AddCtrlOnMainWindow(item.View_);
}
示例7: AttachControl
public override bool AttachControl(FilterPropertiesControl control)
{
Control = control;
Grid grid = new Grid();
int rowIndex = 0;
TextBlock brightnessText = new TextBlock();
brightnessText.Text = "Threshold";
Grid.SetRow(brightnessText, rowIndex++);
Slider brightnessSlider = new Slider();
brightnessSlider.Minimum = 0.0;
brightnessSlider.Maximum = 1.0;
brightnessSlider.Value = _colorSwapFilter.Threshold;
brightnessSlider.ValueChanged += brightnessSlider_ValueChanged;
Grid.SetRow(brightnessSlider, rowIndex++);
for (int i = 0; i < rowIndex; ++i)
{
RowDefinition rd = new RowDefinition();
grid.RowDefinitions.Add(rd);
}
grid.Children.Add(brightnessText);
grid.Children.Add(brightnessSlider);
control.ControlsContainer.Children.Add(grid);
return true;
}
示例8: Meter8
public Meter8()
{
var borderBrush = new LinearGradientBrush();
borderBrush.StartPoint = new Point();
borderBrush.EndPoint = new Point(1d, 1d);
borderBrush.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0d });
borderBrush.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.4999d });
borderBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(0xff, 0x84, 0x7B, 0x6C), Offset = 0.5d });
borderBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(0xff, 0x84, 0x7B, 0x6C), Offset = 1d });
var border = new Rectangle();
border.Fill = borderBrush;
//border.Stroke = new SolidColorBrush(Colors.Black);
//border.StrokeThickness = 1d;
var background = new Rectangle();
background.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0xAD, 0xA7, 0x9D));
background.Margin = new Thickness(4d);
var grid = new Grid();
grid.Children.Add(border);
grid.Children.Add(background);
grid.Children.Add(_canvas);
grid.Children.Add(_calibrationCanvas);
this.Content = grid;
_label.Text = Value.ToString();
_label.Foreground = new SolidColorBrush(ForeColor);
_pointLine.Stroke = new SolidColorBrush(Colors.Red);
_pointLine.StrokeThickness = 2d;
this.SizeChanged += Meter_SizeChanged;
}
示例9: Draw
public override void Draw(Grid g)
{
base.Draw(g);
Rectangle bounds = base.Bounds;
bounds.X += 0x12;
bounds.Width = 400;
}
示例10: InjectOverlayIntoMainWindow
//public static readonly DependencyProperty IsTutorialOverlayCompatibleProperty = DependencyProperty.RegisterAttached("IsTutorialOverlayCompatible", typeof(Boolean), typeof(TutorialManager), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsTutorialOverlayCompatibleChanged));
//public static void SetIsTutorialOverlayCompatible(UIElement element, Boolean value)
//{
// element.SetValue(IsTutorialOverlayCompatibleProperty, value);
//}
//public static Boolean GetIsTutorialOverlayCompatible(UIElement element)
//{
// return (Boolean)element.GetValue(IsTutorialOverlayCompatibleProperty);
//}
public static void InjectOverlayIntoMainWindow()
{
if (OverlayHasBeenInjected)
{
return;
}
Window window = Application.Current.MainWindow;
Grid newRootElement = new Grid();
newRootElement.Name = "HelpOverlayRoot";
if (window.Content as UIElement != null)
{
UIElement currentContent = (UIElement)window.Content;
window.Content = null;
newRootElement.Children.Add(currentContent);
newRootElement.Children.Add(new HelpOverlayControl());
window.Content = newRootElement;
Overlay = (HelpOverlayControl)HelpOverlyHelper.FindChild(newRootElement, "PART_HelpOverlayUserControl");
OverlayHasBeenInjected = true;
}
else
{
Console.WriteLine("HelpOverlay cannot inject its overlay control into a window that defines its root as a DataTemplate. In order to use HelpOverlay, ensure that the current Window's Content property is a UIElement.");
}
}
示例11: Brique
//Constructeur
public Brique(Grid parent, double posX, double posY, bool cassable)
{
//Création de l'ellipse
this._forme = new Rectangle();
//Ajout au parent
parent.Children.Add(this._forme);
//Taille de la Brique
this._forme.Height = 20;
this._forme.Width = 60;
//Position de la Brique
this._forme.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
this._forme.VerticalAlignment = System.Windows.VerticalAlignment.Top;
this._forme.Margin = new System.Windows.Thickness(posX, posY, 0, 0);
this.Cassable = cassable;
//Couleur de la Brique
//Couleur de fond
Thread.Sleep(1);
Random R = new Random(unchecked((int)DateTime.Now.Ticks));
SolidColorBrush couleurFond = new SolidColorBrush();
byte Red = (byte)(R.Next(253) + 1);
byte Green = (byte)(R.Next(253) + 1);
byte Blue = (byte)(R.Next(253) + 1);
//Noire si incassable
couleurFond.Color = cassable ? Color.FromRgb(Red, Green, Blue) : Color.FromRgb(0, 0, 0);
this._forme.Fill = couleurFond;
//Couleur de bordure
SolidColorBrush couleurBord = new SolidColorBrush();
couleurBord.Color = Color.FromRgb(255, 255, 255);
this._forme.Stroke = couleurBord;
}
示例12: GetContent
protected override FrameworkElement GetContent()
{
int totalHeight = 0;
ListBox removeOptions = new ListBox();
for(int i = 0 ; i < _tree.Items.Count; i ++)
if (_tree.Items[i] is PatternBase)
{
totalHeight += 25; //default height of an item
TextBlock pattern = new TextBlock()
{
Text = (_tree.Items[i] as PatternBase).BioPatternName,
Name = i.ToString(), //store the id as name so we can remove it later...
Width = 150
};
pattern.MouseLeftButtonUp += new MouseButtonEventHandler(RemoveSelectedPattern);
removeOptions.Items.Add(pattern);
}
Grid grid = new Grid()
{
Height = totalHeight,
Width = 170
};
grid.Children.Add(removeOptions);
return grid;
}
示例13: Cabecera
public Cabecera()
{
Background = new SolidColorBrush(Colors.White);
Orientation = Orientation.Vertical;
var nombreJuego = new TextBlock { Text = "Tres en Línea", FontSize = 78, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center};
Children.Add(nombreJuego);
var nuevoJuego = new Button {Content = "Iniciar nuevo Juego", Background = new SolidColorBrush(Colors.Black)};
nuevoJuego.Tap += nuevoJuego_Tap;
Children.Add(nuevoJuego);
Grid resultadoGrid = new Grid{Background = new SolidColorBrush(Colors.White), ShowGridLines = false};
resultadoGrid.ColumnDefinitions.Add(new ColumnDefinition());
resultadoGrid.ColumnDefinitions.Add(new ColumnDefinition{Width = new GridLength(2, GridUnitType.Star)});
resultadoGrid.RowDefinitions.Add(new RowDefinition());
var labelResultado = new TextBlock { Text = "Resultado:", FontSize = 22, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
resultadoGrid.Children.Add(labelResultado);
Grid.SetColumn(labelResultado, 0);
resultado = new TextBlock { Text = "En proceso.", FontSize = 22, Foreground = new SolidColorBrush(Colors.Black), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
resultadoGrid.Children.Add(resultado);
Grid.SetColumn(resultado, 1);
Children.Add(resultadoGrid);
}
示例14: AttachControl
public override bool AttachControl(FilterPropertiesControl control)
{
Control = control;
Grid grid = new Grid();
int rowIndex = 0;
CheckBox distinctEdgesCheckBox = new CheckBox();
TextBlock textBlock = new TextBlock {Text = AppResources.DistinctEdges};
distinctEdgesCheckBox.Content = textBlock;
distinctEdgesCheckBox.IsChecked = _cartoonFilter.DistinctEdges;
distinctEdgesCheckBox.Checked += distinctEdgesCheckBox_Checked;
distinctEdgesCheckBox.Unchecked += distinctEdgesCheckBox_Unchecked;
Grid.SetRow(distinctEdgesCheckBox, rowIndex++);
for (int i = 0; i < rowIndex; ++i)
{
RowDefinition rd = new RowDefinition();
grid.RowDefinitions.Add(rd);
}
grid.Children.Add(distinctEdgesCheckBox);
control.ControlsContainer.Children.Add(grid);
return true;
}
示例15: showlocations
private void showlocations()
{
foreach (Place p in _vm.Places)
{
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
BitmapImage bmi = new BitmapImage(new Uri("/Assets/pushpinPhone.png", UriKind.Relative));
Image img = new Image();
img.Tag = (p);
img.Source = bmi;
MyGrid.Children.Add(img);
//Creating a MapOverlay and adding the Grid to it.
MapOverlay MyOverlay = new MapOverlay();
MyOverlay.Content = MyGrid;
MyOverlay.GeoCoordinate = new GeoCoordinate(p.Latitude, p.Longitude);
MyOverlay.PositionOrigin = new Point(0, 0.5);
//Creating a MapLayer and adding the MapOverlay to it
MapLayer MyLayer = new MapLayer();
MyLayer.Add(MyOverlay);
mapWithMyLocation.Layers.Add(MyLayer);
}
}