本文整理汇总了C#中System.Windows.Controls.DataGrid.ScrollIntoView方法的典型用法代码示例。如果您正苦于以下问题:C# DataGrid.ScrollIntoView方法的具体用法?C# DataGrid.ScrollIntoView怎么用?C# DataGrid.ScrollIntoView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.DataGrid
的用法示例。
在下文中一共展示了DataGrid.ScrollIntoView方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScrollToEnd
private static void ScrollToEnd(DataGrid datagrid)
{
if (datagrid.Items.Count == 0)
{
return;
}
datagrid.ScrollIntoView(datagrid.Items[datagrid.Items.Count - 1]);
}
示例2: GetRow
private static DataGridRow GetRow(DataGrid grid, int index)
{
var row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
if (row == null)
{
grid.UpdateLayout();
grid.ScrollIntoView(grid.Items[index]);
row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
}
return row;
}
示例3: GetRow
static public DataGridRow GetRow(DataGrid dg, int index)
{
DataGridRow row = (DataGridRow)dg.ItemContainerGenerator.ContainerFromIndex(index);
if (row == null)
{
// may be virtualized, bring into view and try again
dg.ScrollIntoView(dg.Items[index]);
row = (DataGridRow)dg.ItemContainerGenerator.ContainerFromIndex(index);
}
return row;
}
示例4: ScrollToEnd
private static void ScrollToEnd(DataGrid datagrid)
{
if (datagrid.Items.Count == 0)
return;
int index = datagrid.Items.Count - 1;
object item = datagrid.Items[index];
//if (datagrid.SelectedIndex != -1 && datagrid.SelectedIndex != index)
// return;
datagrid.ScrollIntoView(item);
//datagrid.SelectedItem = null;
}
示例5: DataGridGotoByIndex
public static void DataGridGotoByIndex(DataGrid dtGrid, int index)
{
try
{
if (index < 0 || index > (dtGrid.Items.Count - 1)) return;
dtGrid.SelectedItem = dtGrid.Items[index];
dtGrid.UpdateLayout();
dtGrid.ScrollIntoView(dtGrid.SelectedItem);
}
catch
{
}
}
示例6: DataGridGotoLast
public static void DataGridGotoLast(DataGrid dtGrid)
{
try
{
int index = dtGrid.Items.Count - 1;
if (index >= 0)
{
dtGrid.SelectedItem = dtGrid.Items[index];
dtGrid.UpdateLayout();
dtGrid.ScrollIntoView(dtGrid.SelectedItem);
}
}
catch
{
}
}
示例7: GetCell
static public DataGridCell GetCell(DataGrid dg, int row, int column)
{
DataGridRow rowContainer = GetRow(dg, row);
if (rowContainer != null)
{
DataGridCellsPresenter presenter = VisualHelper.FindVisualChild<DataGridCellsPresenter>(rowContainer);
// try to get the cell but it may possibly be virtualized
DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
if (cell == null)
{
// now try to bring into view and retreive the cell
dg.ScrollIntoView(rowContainer, dg.Columns[column]);
cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column);
}
return cell;
}
return null;
}
示例8: SelectThisID
public void SelectThisID (DataGrid ActuallDataGrid, String IDToSelect)
{
ActuallDataGrid.SelectedItems.Clear ();
foreach (Object RowView in ActuallDataGrid.Items)
{
if (RowView.GetType () == typeof (DataRowView))
if (IDToSelect == ((DataRowView)RowView).Row [IDName].ToString ())
{
ActuallDataGrid.SelectedItem = RowView;
try
{
int IndexToSelect = ActuallDataGrid.Items.IndexOf ((DataRowView) RowView);
ActuallDataGrid.ScrollIntoView (IndexToSelect);
}
catch (Exception Excp)
{
String Message = Excp.ToString();
}
break;
}
}
}
示例9: MakeDataGridRowFocused
public void MakeDataGridRowFocused(DataGrid dg, int index)
{
dg.SelectedItem = dg.Items[index];
dg.ScrollIntoView(dg.Items[index]);
}
示例10: ScrollToSelectedItem
/// <summary>
/// Scrolls to the SelectedItem and first column of a given DataGrid
/// This method must be used as an extension method to the DataGrid class
/// </summary>
/// <param name="dataGrid"></param>
void ScrollToSelectedItem(DataGrid dataGrid)
{
if (dataGrid.SelectedItem == null)
{
return;
}
var itemToScrollTo = dataGrid.SelectedItem;
var columnToScrolTo = dataGrid.Columns[0];
dataGrid.ScrollIntoView(itemToScrollTo, columnToScrolTo);
}
示例11: RecomputeTotals
private async Task RecomputeTotals(DataGrid host, DataTableShim tbl)
{
if (tbl == null) return;
await Task.Delay(100);
var colCount = host.Columns.Count;
var totals = new List<decimal?>();
var isDecimal = new List<bool>();
var row = tbl.NewRow();
for (int j = 0; j < colCount; j++)
{
totals.Add((decimal?)null);
isDecimal.Add(false);
}
object firstItem = null;
foreach (var item in host.ItemsSource)
{
if (firstItem == null) firstItem = item;
if (host.EnableRowVirtualization)
host.ScrollIntoView(item);
for (int j = 0; j < colCount; j++)
{
var cell = host.Columns[j].GetCellContent(item);
totals[j] = TryIncrement(j, totals[j], cell, isDecimal);
}
}
for (int j = 0; j < colCount; j++)
{
if (totals[j] != null && totals[j].HasValue)
{
var f = isDecimal[j] ? "{0:n2}" : "{0:n0}";
row[j] = string.Format(f, totals[j].Value);
}
}
row[0] = "total";
tbl?.Rows?.Clear();
if (row != null) tbl?.Rows?.Add(row);
if (host.EnableRowVirtualization && firstItem != null)
{
//await Task.Delay(1000 * 2);
host.ScrollIntoView(firstItem);
}
}
示例12: GetRow
public static DataGridRow GetRow(DataGrid grid, int index)
{
DataGridRow row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
if (row == null)
{
// May be virtualized, bring into view and try again.
grid.UpdateLayout();
grid.ScrollIntoView(grid.Items[index]);
row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
}
return row;
}
示例13: ReBind
/// <summary>
///
/// </summary>
/// <param name="grid"></param>
/// <param name="step"></param>
public void ReBind(DataGrid grid, int step)
{
int idx = grid.SelectedIndex + step;
if (idx < 0)
{
idx = 0;
}
else if (idx >= _AttList.Count)
{
idx = _AttList.Count - 1;
}
grid.ItemsSource = null;
grid.ItemsSource = _AttList;
grid.SelectedIndex = idx;
grid.UpdateLayout();
grid.ScrollIntoView(grid.SelectedItem, grid.Columns[0]);
}
示例14: ScrollToEnd
private static void ScrollToEnd(DataGrid datagrid)
{
infoDict[datagrid].Timer.Stop();
if (datagrid.Items.Count == 0)
{
return;
}
datagrid.ScrollIntoView(datagrid.Items[datagrid.Items.Count - 1]);
}