本文整理汇总了C#中System.Windows.Controls.ColumnDefinition类的典型用法代码示例。如果您正苦于以下问题:C# ColumnDefinition类的具体用法?C# ColumnDefinition怎么用?C# ColumnDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColumnDefinition类属于System.Windows.Controls命名空间,在下文中一共展示了ColumnDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateColumns
private void UpdateColumns()
{
this.Dispatcher.InvokeAsync(
() =>
{
this.ColumnDefinitions.Clear();
int i = 0;
foreach (FrameworkElement item in this.Children.Cast<FrameworkElement>())
{
EntityGroup entityGroup = (EntityGroup)item.DataContext;
ColumnDefinition columnDefinition = new ColumnDefinition()
{
DataContext = entityGroup
};
Grid.SetColumn(item, i);
if (entityGroup.IsVisible)
{
columnDefinition.SetBinding(ColumnDefinition.WidthProperty, "Width");
}
else
{
columnDefinition.Width = new GridLength(0);
}
this.ColumnDefinitions.Add(columnDefinition);
++i;
}
});
}
示例2: ShowView
private void ShowView(Grid grid)
{
//grid.RowDefinitions.Clear();
//grid.ColumnDefinitions.Clear();
//grid.Children.Clear();
for (int i = 0; i < _Round.ColCount; i += 1)
{
ColumnDefinition col = new ColumnDefinition();
grid.ColumnDefinitions.Add(col);
}
for (int i = 0; i < _Round.RowCount; i += 1)
{
RowDefinition row = new RowDefinition();
grid.RowDefinitions.Add(row);
}
_Ucs = new List<Uc1>(_Round.ColCount * _Round.RowCount);
Uc1 uc;
for (int i = 0; i < _Round.RowCount; i += 1)
{
for (int j = 0; j < _Round.ColCount; j += 1)
{
uc = new Uc1();
uc.SetValue(Grid.RowProperty, i);
uc.SetValue(Grid.ColumnProperty, j);
grid.Children.Add(uc);
_Ucs.Add(uc);
}
}
}
示例3: SetupDetailGrid
private Grid SetupDetailGrid()
{
Grid detailGrid = new Grid();
ColumnDefinition col1 = new ColumnDefinition();
col1.Width = new GridLength(96 * 0.65);
detailGrid.ColumnDefinitions.Add(col1);
ColumnDefinition col2 = new ColumnDefinition();
col2.Width = new GridLength(96 * 2.5);
detailGrid.ColumnDefinitions.Add(col2);
ColumnDefinition col3 = new ColumnDefinition();
col3.Width = new GridLength(96 * 1.65);
detailGrid.ColumnDefinitions.Add(col3);
ColumnDefinition col4 = new ColumnDefinition();
col4.Width = new GridLength(96 * 1.15);
detailGrid.ColumnDefinitions.Add(col4);
ColumnDefinition col5 = new ColumnDefinition();
col5.Width = new GridLength(96 * 1.15);
detailGrid.ColumnDefinitions.Add(col5);
RowDefinition row = new RowDefinition();
detailGrid.RowDefinitions.Add(row);
return detailGrid;
}
示例4: CreateColumnsRows
private void CreateColumnsRows(){
// Create columns
for (int i = 1; i <= columns; i++)
{
ColumnDefinition temp = new ColumnDefinition();
temp.Name = String.Format("c{0}", i);
temp.Width = new GridLength(205, GridUnitType.Pixel);
columnsList.Add(temp);
}
// Create rows
for (int i = 1; i <= rows; i++)
{
RowDefinition temp = new RowDefinition();
temp.Name = String.Format("c{0}", i);
temp.Height = new GridLength(205, GridUnitType.Pixel);
rowsList.Add(temp);
}
// Add Columns and Rows to Grid
foreach (ColumnDefinition tempColumn in columnsList)
{
mainGrid.ColumnDefinitions.Add(tempColumn);
}
foreach (RowDefinition tempRow in rowsList)
{
mainGrid.RowDefinitions.Add(tempRow);
}
}
示例5: DrawGameBoard
private void DrawGameBoard(int desiredSlots)
{
RowDefinition[] rowDefinitions = new RowDefinition[desiredSlots];
ColumnDefinition[] columnDefinitions = new ColumnDefinition[desiredSlots];
for (int i = 0; i < desiredSlots; i++)
{
rowDefinitions[i] = new RowDefinition();
columnDefinitions[i] = new ColumnDefinition();
grdGameBoard.RowDefinitions.Add(rowDefinitions[i]);
grdGameBoard.ColumnDefinitions.Add(columnDefinitions[i]);
}
for (int i = 0; i < grdGameBoard.RowDefinitions.Count; i++)
{
for (int j = 0; j < grdGameBoard.ColumnDefinitions.Count; j++)
{
var slot = new TextBox();
slot.Margin = new Thickness(5);
slot.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
slot.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
Grid.SetRow(slot, i);
Grid.SetColumn(slot, j);
grdGameBoard.Children.Add(slot);
}
}
}
示例6: CreateList
/// <summary>
/// Kreiranje listview-a na temelju liste objetata u parametru.
/// </summary>
/// <param name="classesList"></param>
public void CreateList(List<object> classesList)
{
foreach (String[] classArrayString in classesList) {
Grid grid = new Grid();
grid.ShowGridLines = true;
grid.RowDefinitions.Add(new RowDefinition());
grid.Margin = new Thickness(30, 10, 30, 0);
for (int i=0; i < classArrayString.Length; i++) {
ColumnDefinition columnDef = new ColumnDefinition();
columnDef.Width = new GridLength(150);
grid.ColumnDefinitions.Add(columnDef);
Label label = new Label();
label.Content = classArrayString[i];
Grid.SetColumn(label, i);
Grid.SetRow(label, 0);
grid.Children.Add(label);
}
ListViewItem listItem = new ListViewItem();
listItem.Content = grid;
currentListView.Items.Add(listItem);
}
}
示例7: ShowGrid
public Grid ShowGrid()
{
Grid grid = new Grid();
for (var i = 0; i < tileLayer.Count; i++)
{
RowDefinition row = new RowDefinition();
grid.RowDefinitions.Add(row);
for (var j = 0; j < tileLayer[i].Count; j++)
{
ColumnDefinition col = new ColumnDefinition();
grid.ColumnDefinitions.Add(col);
List<Tile> sublist = tileLayer[i];
Tile temp = sublist[j];
Image img = new Image();
img.Source = temp.BackgroundImage;
img.SetValue(Grid.ColumnProperty, j);
img.SetValue(Grid.RowProperty, i);
img.Stretch = Stretch.UniformToFill;
grid.Children.Add(img);
}
}
return grid;
}
示例8: display
public void display()
{
playArea.ColumnDefinitions.Clear();
playArea.RowDefinitions.Clear();
ColumnDefinition[] colDefs = new ColumnDefinition[testMap.x];
RowDefinition[] rowDefs = new RowDefinition[testMap.y];
testMap.populate();
for (int i = 0; i < testMap.x; i++)
{
colDefs[i] = new ColumnDefinition();
playArea.ColumnDefinitions.Add(colDefs[i]);
}
for (int i = 0; i < testMap.y; i++)
{
rowDefs[i] = new RowDefinition();
playArea.RowDefinitions.Add(rowDefs[i]);
}
for (int i = 0; i < testMap.x; i++)
{
for (int j = 0; j < testMap.y; j++)
{
playArea.Children.Add(testMap.layout[i][j]);
Grid.SetRow(testMap.layout[i][j], j);
Grid.SetColumn(testMap.layout[i][j], i);
}
}
}
示例9: FillMasterGrid
public void FillMasterGrid(IEnumerable<Grid> lyricGrids, Grid masterGrid)
{
// Create the Grid
masterGrid.Width = 510; //TODO: Auto width
masterGrid.HorizontalAlignment = HorizontalAlignment.Left;
masterGrid.VerticalAlignment = VerticalAlignment.Top;
masterGrid.ShowGridLines = false;
masterGrid.Background = new SolidColorBrush(Colors.LightSteelBlue);
//add one column
var column = new ColumnDefinition { Width = GridLength.Auto };
masterGrid.ColumnDefinitions.Add(column);
// Create Rows
var row = new RowDefinition { Height = GridLength.Auto };
masterGrid.RowDefinitions.Add(row);
// fill rows with lyric grids
var lGrids = lyricGrids.ToList();
for (var i = 0; i < lGrids.Count(); i++)
{
var lyricGrid = lGrids[i];
Grid.SetRow(lyricGrid, i);
Grid.SetColumn(lyricGrid, 0);
masterGrid.Children.Add(lyricGrid);
}
}
示例10: Layer_Two
public Layer_Two()
: base()
{
titleBlock = new TextBlock();
titleBlock.Width = STATICS.DEAULT_CARD_SIZE.Width;
titleBlock.Foreground = new SolidColorBrush(Colors.Black);
titleBlock.LineHeight = 1;
titleBlock.TextWrapping = TextWrapping.Wrap;
titleBlock.HorizontalAlignment = HorizontalAlignment.Left;
titleBlock.TextAlignment = TextAlignment.Left;
titleBlock.FontStretch = FontStretches.Normal;
titleBlock.Margin = new Thickness(3);
this.Children.Add(titleBlock);
Grid.SetRow(titleBlock, 0);
Grid.SetColumn(titleBlock, 0);
Grid.SetColumnSpan(titleBlock, 2);
RowDefinition rd = new RowDefinition();
rd.Height = new GridLength(STATICS.DEAULT_CARD_SIZE.Height-1.5* STATICS.ZOOMWHEEL_RADIUS);
this.RowDefinitions.Add(rd);
rd = new RowDefinition();
rd.Height = new GridLength(STATICS.ZOOMWHEEL_RADIUS);
this.RowDefinitions.Add(rd);
ColumnDefinition gridCol1 = new ColumnDefinition();
gridCol1.Width = new GridLength(this.Width / 2);
this.ColumnDefinitions.Add(gridCol1);
ColumnDefinition gridCol2 = new ColumnDefinition();
gridCol2.Width = new GridLength(this.Width / 2);
this.ColumnDefinitions.Add(gridCol2);
}
示例11: SetupClientInfoGrid
private Grid SetupClientInfoGrid()
{
Grid grid = new Grid();
RowDefinition row = new RowDefinition();
grid.RowDefinitions.Add(row);
ColumnDefinition col1 = new ColumnDefinition();
col1.Width = new GridLength(96 * 2);
grid.ColumnDefinitions.Add(col1);
ColumnDefinition col2 = new ColumnDefinition();
col2.Width = new GridLength(96 * 1.3);
grid.ColumnDefinitions.Add(col2);
ColumnDefinition col3 = new ColumnDefinition();
col3.Width = new GridLength(96 * .9);
grid.ColumnDefinitions.Add(col3);
ColumnDefinition col4 = new ColumnDefinition();
col4.Width = new GridLength(96 * .7);
grid.ColumnDefinitions.Add(col4);
ColumnDefinition col5 = new ColumnDefinition();
col5.Width = new GridLength(96 * .9);
grid.ColumnDefinitions.Add(col5);
ColumnDefinition col6 = new ColumnDefinition();
col6.Width = new GridLength(96 * 1.3);
grid.ColumnDefinitions.Add(col6);
return grid;
}
示例12: CreateHotKeyControl
public Grid CreateHotKeyControl()
{
this.grid.Width = 300;
this.grid.HorizontalAlignment = HorizontalAlignment.Left;
ColumnDefinition col0 = new ColumnDefinition();
ColumnDefinition col1 = new ColumnDefinition();
ColumnDefinition col2 = new ColumnDefinition();
this.grid.ColumnDefinitions.Add(col0);
this.grid.ColumnDefinitions.Add(col1);
this.grid.ColumnDefinitions.Add(col2);
RowDefinition row0 = new RowDefinition();
this.grid.RowDefinitions.Add(row0);
this.label.Width = 60;
this.label.HorizontalAlignment = HorizontalAlignment.Left;
this.label.Margin = new Thickness(10);
Grid.SetColumn(this.label, 0);
Grid.SetRow(this.label, 0);
this.comboBox.Width = 60;
this.comboBox.HorizontalAlignment = HorizontalAlignment.Left;
this.comboBox.Margin = new Thickness(10);
Grid.SetColumn(this.comboBox, 1);
Grid.SetRow(this.comboBox, 0);
this.textBox.Width = 60;
this.textBox.HorizontalAlignment = HorizontalAlignment.Left;
this.textBox.Margin = new Thickness(10);
Grid.SetColumn(this.textBox, 2);
Grid.SetRow(this.textBox, 0);
this.grid.Children.Add(this.label);
this.grid.Children.Add(this.comboBox);
this.grid.Children.Add(this.textBox);
return this.grid;
}
示例13: AddTwice
public void AddTwice ()
{
ColumnDefinitionCollection c = new Grid ().ColumnDefinitions;
ColumnDefinition d = new ColumnDefinition ();
c.Add (d);
c.Add (d);
}
示例14: CollapseColumn
void CollapseColumn(GridSplitter splitter, ColumnDefinition def, string content)
{
// Ignore collapse if popup is opened
if (PopupManager.ActivePopup != null)
return;
int collapsed = 0;
// Count the number of collapsed items (exclusing collapseView and rockScroll)
for (int i = 0; i < OverviewContainerRootGrid.ColumnDefinitions.Count -2; i++)
{
if (OverviewContainerRootGrid.ColumnDefinitions[i].Width.Value == 0)
collapsed++;
}
// Only allowed to collapse when there are at least two columns which have Width > 0
if (collapsed >= OverviewContainerRootGrid.ColumnDefinitions.Count - 3)
return;
GridColumnSizeHelper.SetPreviousGridLength(def, def.Width);
//Start Collapse Column Animation, only when the column Width != 0
if (def.Width != new GridLength(0))
{
Storyboard CollapseColumnGrid = (Storyboard)FindResource("CollapseColumn");
Storyboard.SetTarget(CollapseColumnGrid, def);
GridLengthAnimation gla = CollapseColumnGrid.Children[0] as GridLengthAnimation;
gla.From = def.Width;
gla.To = new GridLength(0);
CollapseColumnGrid.Begin(this);
}
if (splitter != null)
splitter.IsEnabled = false;
collapseView.AddCollapsedView(def, content, delegate
{
//Start Expand Column Animation, only when the column Width = 0
if (def.Width == new GridLength(0))
{
def.Width = GridColumnSizeHelper.GetPreviousGridLength(def);
GridLength previousWidth = def.Width;
def.Width = new GridLength(0);
Storyboard ExpandColumnGrid = (Storyboard)FindResource("CollapseColumn");
Storyboard.SetTarget(ExpandColumnGrid, def);
GridLengthAnimation gla = ExpandColumnGrid.Children[0] as GridLengthAnimation;
gla.From = new GridLength(0);
gla.To = previousWidth;
ExpandColumnGrid.Begin(this);
}
if (splitter != null)
splitter.IsEnabled = true;
});
}
示例15: GetNewKeymapGrid
public static Grid GetNewKeymapGrid(int numRows, int numCols, Keymap[,] keymaps)
{
var keymapGrid = new Grid();
keymapGrid.Children.Clear();
var rows = new RowDefinition[numRows];
var columns = new ColumnDefinition[numCols];
for (var i = 0; i < numRows; i++)
{
rows[i] = new RowDefinition();
keymapGrid.RowDefinitions.Add(rows[i]);
}
for (var i = 0; i < numCols; i++)
{
columns[i] = new ColumnDefinition();
keymapGrid.ColumnDefinitions.Add(columns[i]);
}
for (var i = 0; i < numRows; i++)
{
for (var j = 0; j < numCols; j++)
{
var button = new Button();
keymaps[i, j].Button = button;
Grid.SetRow(button, i);
Grid.SetColumn(button, j);
keymapGrid.Children.Add(button);
}
}
return keymapGrid;
}