本文整理汇总了C#中System.Windows.Controls.RowDefinition.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# RowDefinition.SetBinding方法的具体用法?C# RowDefinition.SetBinding怎么用?C# RowDefinition.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.RowDefinition
的用法示例。
在下文中一共展示了RowDefinition.SetBinding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateRows
/// <summary>
/// Updates the rows.
/// </summary>
/// <param name="rows">The number rows.</param>
private void UpdateRows(int rows)
{
this.rowGrid.Children.Add(this.rowSelectionBackground);
for (var i = 0; i < rows; i++)
{
var sheetDefinition = new System.Windows.Controls.RowDefinition { Height = this.GetRowHeight(i) };
this.sheetGrid.RowDefinitions.Add(sheetDefinition);
var rowDefinition = new System.Windows.Controls.RowDefinition();
rowDefinition.SetBinding(System.Windows.Controls.RowDefinition.HeightProperty, new Binding { Source = sheetDefinition, Path = new PropertyPath("Height"), Mode = BindingMode.TwoWay });
this.rowGrid.RowDefinitions.Add(rowDefinition);
}
for (var i = 0; i < rows; i++)
{
var header = this.GetRowHeader(i);
var border = new Border
{
BorderBrush = this.HeaderBorderBrush,
BorderThickness = new Thickness(1, 0, 1, 1),
Margin = new Thickness(0, 0, 0, -1)
};
Grid.SetRow(border, i);
this.rowGrid.Children.Add(border);
var cell = header as FrameworkElement
??
new TextBlock
{
Text = header?.ToString() ?? "-",
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
Padding = new Thickness(4, 2, 4, 2)
};
if (this.ItemHeaderPropertyPath != null && this.ItemsInRows)
{
cell.DataContext = this.Operator.GetItem(this, new CellRef(i, -1));
cell.SetBinding(TextBlock.TextProperty, new Binding(this.ItemHeaderPropertyPath));
}
if (this.RowHeadersSource != null && this.ItemsInRows)
{
cell.DataContext = this.RowHeadersSource;
cell.SetBinding(
TextBlock.TextProperty,
new Binding($"[{i}]") { StringFormat = this.RowHeadersFormatString });
}
Grid.SetRow(cell, i);
this.rowGrid.Children.Add(cell);
this.rowHeaderMap[i] = cell;
}
// Add "Insert" row header
this.AddInserterRow(rows);
// set the context menu
this.rowGrid.ContextMenu = this.RowsContextMenu;
// to cover a possible scrollbar
this.rowGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition { Height = new GridLength(20) });
for (var j = 0; j < rows; j++)
{
if (this.CanResizeRows)
{
var splitter = new GridSplitter
{
ResizeDirection = GridResizeDirection.Rows,
Background = Brushes.Transparent,
Height = 5,
RenderTransform = new TranslateTransform(0, 3),
Focusable = false,
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch
};
splitter.MouseDoubleClick += this.RowSplitterDoubleClick;
splitter.DragStarted += this.RowSplitterChangeStarted;
splitter.DragDelta += this.RowSplitterChangeDelta;
splitter.DragCompleted += this.RowSplitterChangeCompleted;
Grid.SetRow(splitter, j);
this.rowGrid.Children.Add(splitter);
}
}
}
示例2: UpdateGrid
void UpdateGrid()
{
if (_grid == null)
return;
_grid.ColumnDefinitions.Clear();
_grid.RowDefinitions.Clear();
if (_converter == null)
_converter = new LayoutOptionsToLengthConverter();
if (_orientation == Orientation.Vertical)
{
for (int i = 0; i < ItemsControl.Items.Count; i++)
{
var element = _grid.Children.OfType<UIElement>().Skip(i).First();
WPFGrid.SetRow(element, i);
WPFGrid.SetColumn(element, 0);
var row = new WPFRowDefinition { Height = new WPFGridLength(0, WPFGridUnitType.Auto) };
_grid.RowDefinitions.Add(row);
var binding = new System.Windows.Data.Binding(View.VerticalOptionsProperty.PropertyName)
{
Source = ItemsSource.Skip(i).FirstOrDefault(),
Converter = _converter
};
row.SetBinding(WPFRowDefinition.HeightProperty, binding);
}
}
else
{
for (int i = 0; i < ItemsControl.Items.Count; i++)
{
var element = _grid.Children.OfType<UIElement>().Skip(i).First();
WPFGrid.SetRow(element, 0);
WPFGrid.SetColumn(element, i);
var col = new WPFColumnDefinition { Width = new WPFGridLength(0, WPFGridUnitType.Auto) };
_grid.ColumnDefinitions.Add(col);
var binding = new System.Windows.Data.Binding(View.HorizontalOptionsProperty.PropertyName)
{
Source = ItemsSource.Skip(i).FirstOrDefault(),
Converter = _converter
};
col.SetBinding(WPFColumnDefinition.WidthProperty, binding);
}
}
}