本文整理汇总了C#中System.Windows.Controls.DataGridCell类的典型用法代码示例。如果您正苦于以下问题:C# DataGridCell类的具体用法?C# DataGridCell怎么用?C# DataGridCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridCell类属于System.Windows.Controls命名空间,在下文中一共展示了DataGridCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateEditingElement
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
NumericUpDown numericUpDown = new NumericUpDown();
ApplyColumnProperties(numericUpDown);
numericUpDown.VerticalAlignment = VerticalAlignment.Center;
return numericUpDown;
}
示例2: GenerateEditingElement
/// <summary>
/// Gets a <see cref="T:System.Windows.Controls.TextBox" /> control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.
/// </summary>
/// <param name="cell">The cell that will contain the generated element.</param>
/// <param name="dataItem">The data item represented by the row that contains the intended cell.</param>
/// <returns>
/// A new text box control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.
/// </returns>
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
TextBox textBox = (TextBox)base.GenerateEditingElement(cell, dataItem);
textBox.GotFocus += this.OnTextBoxGotFocus;
DataGridColumnToolTipHelper.SetToolTip(textBox, this.ToolTip, this.ToolTipTemplate, dataItem);
return textBox;
}
示例3: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
StackPanel panel = GeneratePanel(dataItem);
panel.Children.Add(base.GenerateElement(cell,dataItem));
return panel;
}
示例4: GenerateEditingElement
// データ編集用コントロールの設定
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, Object dataItem)
{
TextBox textBox = (TextBox)base.GenerateEditingElement(cell, dataItem);
// 最大桁数
textBox.MaxLength = 5;
// 垂直方向配置
textBox.VerticalContentAlignment = VerticalAlignment.Center;
// 水平方向配置
textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
// IMEを強制的にOFF
textBox.SetValue(InputMethod.IsInputMethodEnabledProperty, false);
// 折り返し表示の禁止
textBox.TextWrapping = TextWrapping.NoWrap;
// Enterによるフォーカス移動
textBox.SetValue(EnterThenNextFocus.EnterThenNextFocusProperty, true);
// フォーカス取得時にテキスト全選択
textBox.SetValue(SelectOnFocus.SelectOnFocusProperty, true);
// 時刻フォーマット変換
textBox.SetValue(TimeFormat.TimeFormatProperty, true);
// 入力可能文字列の制限
textBox.SetValue(InputCharcter.InputCharcterProperty, RegexCheck.InputChar.Time_Only);
// 表示フォーマット
string stringFormat = (String)this.GetValue(DisplayFormat.DisplayFormatProperty);
base.SetStringFormat(textBox, stringFormat);
return textBox;
}
示例5: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
if (!string.IsNullOrEmpty(this.Resource) && !string.IsNullOrEmpty(this.CustomResourceFormat))
{
Image icon = UiHelper.CreateIcon(UriResources.GetImage(String.Format(this.CustomResourceFormat,this.Resource)));
return icon;
}
if (!string.IsNullOrEmpty(this.Resource))
{
if (dataItem is KpiView && Resource == "Status")
{
Image icon = UiHelper.CreateIcon(UriResources.GetImage(GetKpiIconByPath(this.Resource,(dataItem as KpiView).StatusGraphic)));
return icon;
}
if (dataItem is KpiView && Resource == "Trend")
{
Image icon = UiHelper.CreateIcon(UriResources.GetImage(GetKpiIconByPath(this.Resource,(dataItem as KpiView).TrendGraphic)));
return icon;
}
}
TextBlock block = new TextBlock();
block.Margin = new Thickness(4.0);
block.VerticalAlignment = VerticalAlignment.Center;
block.Text = dataItem.ToString();
return block;
}
示例6: GenerateEditingElement
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
DatePicker picker = new DatePicker();
picker.SetBinding(DatePicker.SelectedDateProperty, this.Binding);
picker.IsDropDownOpen = true;
return picker;
}
示例7: GetRowAndColumnIndicesFromGivenCell
private List<Tuple<int, int>> GetRowAndColumnIndicesFromGivenCell(DataGrid dataGrid, DataGridCell cell)
{
List<Tuple<int, int>> cellList = null;
var columnIndex = cell.Column.DisplayIndex;
var parent = VisualTreeHelper.GetParent(cell);
while (parent != null && parent.GetType() != typeof (DataGridRow))
{
parent = VisualTreeHelper.GetParent(parent);
}
if (parent is DataGridRow)
{
var dataGridRow = parent as DataGridRow;
var item = dataGridRow.Item;
if (item != null)
{
var rowIndex = dataGrid.Items.IndexOf(item);
if (rowIndex != -1)
{
cellList = new List<Tuple<int, int>>()
{
new Tuple<int, int>(rowIndex, columnIndex)
};
}
}
}
return cellList;
}
示例8: GenerateEditingElement
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
CheckBox checkBox = new CheckBox();
//
checkBox.Margin = new Thickness(0);
ConfigureCheckBox(checkBox);
return checkBox;
}
示例9: DataGridCellAutomationPeer
/// <summary>
/// AutomationPeer for DataGridCell.
/// This automation peer should not be part of the automation tree.
/// It should act as a wrapper peer for DataGridCellItemAutomationPeer
/// </summary>
/// <param name="owner">DataGridCell</param>
public DataGridCellAutomationPeer(DataGridCell owner)
: base(owner)
{
if (owner == null)
{
throw new ArgumentNullException("owner");
}
}
示例10: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
var binding = new Binding(((Binding)Binding).Path.Path);
binding.Source = dataItem;
var content = new ContentControl();
content.ContentTemplate = (DataTemplate)cell.FindResource(TemplateName);
content.SetBinding(ContentControl.ContentProperty, binding); return content;
}
示例11: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
var element = new DatePicker
{
Style = Application.Current.Resources["DatePickerStyle"] as Style
};
element.SetBinding(DatePicker.SelectedDateProperty, Binding);
return element;
}
示例12: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
FrameworkElement frameworkElement = base.GenerateElement(cell, dataItem);
Binding binding = new Binding(this.ColumnName) {
Source = dataItem
};
frameworkElement.SetBinding(ContentControl.ContentProperty, binding);
return frameworkElement;
}
示例13: GetRowIndex
public static int GetRowIndex(DataGridCell dataGridCell)
{
// Use reflection to get DataGridCell.RowDataItem property value.
PropertyInfo rowDataItemProperty = dataGridCell.GetType().GetProperty("RowDataItem", BindingFlags.Instance | BindingFlags.NonPublic);
DataGrid dataGrid = GetDataGridFromChild(dataGridCell);
return dataGrid.Items.IndexOf(rowDataItemProperty.GetValue(dataGridCell, null));
}
示例14: GenerateEditingElement
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
var checkBox = (CheckBox)base.GenerateEditingElement(cell, dataItem);
checkBox.Checked += checkBox_Checked;
checkBox.Unchecked += checkBox_Unchecked;
return checkBox;
}
示例15: GenerateElement
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
{
var comboBox = base.GenerateElement(cell, cell);
if (ItemsSourceBinding != null)
comboBox.SetBinding(ItemsControl.ItemsSourceProperty, ItemsSourceBinding);
ApplyStyle(false, false, comboBox);
return comboBox;
}