本文整理汇总了C#中System.Windows.Controls.GridView类的典型用法代码示例。如果您正苦于以下问题:C# GridView类的具体用法?C# GridView怎么用?C# GridView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridView类属于System.Windows.Controls命名空间,在下文中一共展示了GridView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PluginWindow
public PluginWindow()
{
InitializeComponent();
_plugins = new Plugins();
var gridView = new GridView();
listViewPlugins.View = gridView;
gridView.Columns.Add(new GridViewColumn
{
Header = "Name",
DisplayMemberBinding = new Binding("Name")
});
gridView.Columns.Add(new GridViewColumn
{
Header = "Status",
DisplayMemberBinding = new Binding("Status")
});
gridView.Columns.Add(new GridViewColumn
{
Header = "EventStart",
DisplayMemberBinding = new Binding("EventStart")
});
foreach (var item in new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })
{
listViewPlugins.Items.Add(new { Name = "plugin " + item.ToString(), EventStart = "onLoad", Status = "Enable" });
}
}
示例2: TableVisualiserPattern
public TableVisualiserPattern()
{
InitializeComponent();
TableListView.Width = Width - 50;
TableListView.Height = Height - 50;
var objCollection = SqlRepository.Schedules; //input smthing
// var obj = objCollection.Cast<Models.Schedule>().FirstOrDefault();
var objType = typeof(Models.Schedule);
var gridView = new GridView();
TableListView.View = gridView;
foreach (var prop in objType.GetProperties().Where(prop => prop.PropertyType.IsPrimitive
|| prop.PropertyType == typeof(string)
|| prop.PropertyType == typeof(DateTime)))
{
gridView.Columns.Add(new GridViewColumn() { Header = prop.Name, DisplayMemberBinding = new Binding(prop.Name) });
}
foreach (var o in objCollection.Cast<Models.Schedule>())
{
TableListView.Items.Add(o);
}
}
示例3: Fenetre_Classement
public Fenetre_Classement()
{
InitializeComponent();
CT_Get_Classement CT = new CT_Get_Classement();
Joueur[] classement = (Joueur[])CT.Exec(new Message()).Data[0];
GridView view = new GridView();
GridViewColumn col1 = new GridViewColumn();
col1.Header = "Nom";
col1.DisplayMemberBinding = new Binding("Nom");
view.Columns.Add(col1);
GridViewColumn col2 = new GridViewColumn();
col2.Header = "Score";
col2.DisplayMemberBinding = new Binding("Score");
view.Columns.Add(col2);
view.AllowsColumnReorder = false;
this.ClassementListView.View = view;
foreach (Joueur j in classement)
{
this.ClassementListView.Items.Add(new Item(j.Nom, j.Score));
}
}
示例4: ListSystemParameters
public ListSystemParameters()
{
Title = "List System Parameters";
ListView lstvue = new ListView();
Content = lstvue;
GridView grdvue = new GridView();
lstvue.View = grdvue;
GridViewColumn col = new GridViewColumn();
col.Header = "Property Name";
col.Width = 200;
col.DisplayMemberBinding = new Binding("Name");
grdvue.Columns.Add(col);
col = new GridViewColumn();
col.Header = "Value";
col.Width = 200;
col.DisplayMemberBinding = new Binding("Value");
grdvue.Columns.Add(col);
PropertyInfo[] props = typeof(SystemParameters).GetProperties();
foreach (PropertyInfo prop in props)
{
if (prop.PropertyType != typeof(ResourceKey))
{
SystemParam sysparam = new SystemParam();
sysparam.Name = prop.Name;
sysparam.Value = prop.GetValue(null, null);
lstvue.Items.Add(sysparam);
}
}
}
示例5: TabularDataViewer
public TabularDataViewer(IBioLinkReport report, DataMatrix data, IProgressObserver progress)
{
InitializeComponent();
this.Data = data;
_progress = progress;
_report = report;
var view = new GridView();
var columns = report.DisplayColumns;
if (columns == null || columns.Count == 0) {
columns = GenerateDefaultColumns(data);
}
var hcs = viewerGrid.Resources["hcs"] as Style;
foreach (DisplayColumnDefinition c in columns) {
DisplayColumnDefinition coldef = c;
var column = new GridViewColumn { Header = BuildColumnHeader(coldef), DisplayMemberBinding = new Binding(String.Format("[{0}]", data.IndexOf(coldef.ColumnName))), HeaderContainerStyle = hcs };
view.Columns.Add(column);
}
lvw.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));
lvw.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(lvw_MouseRightButtonUp);
lvw.ItemsSource = Data.Rows;
this.lvw.View = view;
}
示例6: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
GridView myGridView = new GridView();
myGridView.AllowsColumnReorder = true;
//Collapse the header
Style collapsedHeaderStyle = new Style();
Setter collapsedHeaderSetter = new Setter();
collapsedHeaderSetter.Property = VisibilityProperty;
collapsedHeaderSetter.Value = Visibility.Collapsed;
collapsedHeaderStyle.Setters.Add(collapsedHeaderSetter);
myGridView.ColumnHeaderContainerStyle = collapsedHeaderStyle;
for (int i = 0; i < control.XSize; i++)
{
GridViewColumn col = new GridViewColumn();
col.DisplayMemberBinding = new Binding("Column[" + i.ToString() + "]");
col.Width = 30;
myGridView.Columns.Add(col);
}
listView.View = myGridView;
listView.DataContext = control.AgentCollection;
}
示例7: BuildDockingLayout
void BuildDockingLayout()
{
dockManager.Content = null;
//TreeView dockable content
var trv = new TreeView();
trv.Items.Add(new TreeViewItem() { Header = "Item1" });
trv.Items.Add(new TreeViewItem() { Header = "Item2" });
trv.Items.Add(new TreeViewItem() { Header = "Item3" });
trv.Items.Add(new TreeViewItem() { Header = "Item4" });
((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem1" });
((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem2" });
((TreeViewItem)trv.Items[1]).Items.Add(new TreeViewItem() { Header = "SubItem3" });
((TreeViewItem)trv.Items[2]).Items.Add(new TreeViewItem() { Header = "SubItem4" });
var treeviewContent = new DockableContent() { Title = "Explorer", Content = trv };
treeviewContent.Show(dockManager, AnchorStyle.Bottom);
//TextBox invo dockable content
var treeviewInfoContent = new DockableContent() { Title = "Explorer Info", Content = new TextBox() { Text = "Explorer Info Text", IsReadOnly = true } };
treeviewContent.ContainerPane.Items.Add(treeviewInfoContent);
//ListView dockable content
var gridView = new GridView();
gridView.Columns.Add(new GridViewColumn() { Header = "Date" });
gridView.Columns.Add(new GridViewColumn() { Header = "Day Of Weeek", DisplayMemberBinding = new Binding("DayOfWeek") });
gridView.Columns.Add(new GridViewColumn() { Header = "Year", DisplayMemberBinding = new Binding("Year") });
gridView.Columns.Add(new GridViewColumn() { Header = "Month", DisplayMemberBinding = new Binding("Month") });
gridView.Columns.Add(new GridViewColumn() { Header = "Second", DisplayMemberBinding = new Binding("Second") });
var listView = new ListView() { View = gridView };
listView.Items.Add(DateTime.Now);
listView.Items.Add(DateTime.Now.AddYears(-1));
listView.Items.Add(DateTime.Now.AddMonths(15));
listView.Items.Add(DateTime.Now.AddHours(354));
var listViewContent = new DockableContent() { Title = "Date & Times", Content = listView };
listViewContent.ShowAsFloatingWindow(dockManager, true);
//TextBox dockable content
var textboxSampleContent = new DockableContent() { Title = "Date & Times Info", Content = new TextBox() { Text = "Date & Times Info Text", IsReadOnly = true } };
listViewContent.ContainerPane.Items.Add(textboxSampleContent);
//DataGrid document
//var dataGrid = new DataGrid();
//var rnd = new Random();
//var data = new List<Tuple<double, double, double, double>>();
//for (int i = 0; i < 100; i++)
//{
// data.Add(Tuple.Create(rnd.NextDouble(), rnd.NextDouble() * 10.0, rnd.NextDouble() * 100.0, rnd.NextDouble() * 1000.0));
//}
//dataGrid.ItemsSource = data;
//var dataGridDocument = new DocumentContent() { Title = "Data", IsLocked = true, Content = dataGrid };
//dataGridDocument.Show(dockManager);
////DataGrid Info Text sample
//var dataGridInfoContent = new DockableContent() { Title = "Data Info", Content = new TextBox() { Text = "Data Info Text" } };
//dataGridInfoContent.ShowAsDocument(dockManager);
}
示例8: SetAlarmList
public void SetAlarmList()
{
GridView gridView = new GridView();
GridViewColumn column = new GridViewColumn();
column.Header = "ALARM NO";
column.Width = double.NaN;
column.DisplayMemberBinding = new System.Windows.Data.Binding("AlarmNo");
gridView.Columns.Add(column);
column = new GridViewColumn();
column.Header = "NAME";
column.Width = double.NaN;
column.DisplayMemberBinding = new System.Windows.Data.Binding("AlarmName");
gridView.Columns.Add(column);
//column = new GridViewColumn();
//column.Header = "DESCRIPTION";
//column.Width = double.NaN;
//column.DisplayMemberBinding = new System.Windows.Data.Binding("Description");
//gridView.Columns.Add(column);
column = new GridViewColumn();
column.Header = "SOLUTION";
column.Width = double.NaN;
column.DisplayMemberBinding = new System.Windows.Data.Binding("Solution");
gridView.Columns.Add(column);
listViewAlarmList.View = gridView;
listViewAlarmList.FontFamily = new FontFamily("Tahoma");
listViewAlarmList.FontSize = 16;
listViewAlarmList.FontWeight = FontWeights.Bold;
}
示例9: AllAncestorsTest
public void AllAncestorsTest()
{
var gridView = new GridView();
var gridViewColumn = new GridViewColumn();
gridView.Columns.Add(gridViewColumn);
Assert.AreEqual(gridView, gridViewColumn.AllAncestors().First());
}
示例10: AddStyleColumn
private void AddStyleColumn(FontStyleData fontStyle, GridView gridView)
{
DataTemplate dataTemplate = (DataTemplate) XamlReader.Parse(string.Format(DATA_TEMPLATE_TEMPLATE, fontStyle.FontWeight, fontStyle.FontStyle, fontStyle.FontSize, fontStyle.TextDecoration));
GridViewColumn column = new GridViewColumn() { Header = fontStyle.Name };
column.CellTemplate = dataTemplate;
gridView.Columns.Add(column);
}
示例11: GetGridView
private GridView GetGridView(List<dynamic> list)
{
GridView gridView = new GridView();
int i = 0;
foreach (dynamic item in list)
{
GridViewColumn col = new GridViewColumn();
col.Header = item.Name;
if (item.Type == "System.Boolean")
{
System.Windows.DataTemplate template = new System.Windows.DataTemplate();
System.Windows.FrameworkElementFactory checkBox =
new System.Windows.FrameworkElementFactory(typeof(CheckBox));
checkBox.SetValue(CheckBox.VerticalAlignmentProperty, System.Windows.VerticalAlignment.Center);
Binding bd = new Binding("[" + i.ToString() + "].Value");
bd.Mode = BindingMode.OneTime;
checkBox.SetBinding(CheckBox.IsCheckedProperty, bd);
template.VisualTree = checkBox;
col.CellTemplate = template;
}
else
{
col.DisplayMemberBinding = new System.Windows.Data.Binding("[" + i.ToString() + "].Value");
}
gridView.Columns.Add(col);
i++;
}
return gridView;
}
示例12: MainWindow
public MainWindow()
{
InitializeComponent();
// 以下を追加
this.btnDownload.Click += (sender, e) =>
{
var client = new System.Net.WebClient();
byte[] buffer = client.DownloadData("http://k-db.com/?p=all&download=csv");
string str = Encoding.Default.GetString(buffer);
string[] rows = str.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
// 1行目をラベルに表示
this.lblTitle.Content = rows[0];
// 2行目以下はカンマ区切りから文字列の配列に変換しておく
List<string[]> list = new List<string[]>();
rows.ToList().ForEach(row => list.Add(row.Split(new char[] { ',' })));
// ヘッダの作成(データバインド用の設計)
GridView view = new GridView();
list.First().Select((item, cnt) => new { Count = cnt, Item = item }).ToList().ForEach(header =>
{
view.Columns.Add(
new GridViewColumn()
{
Header = header.Item,
DisplayMemberBinding = new Binding(string.Format("[{0}]", header.Count))
});
});
// これらをリストビューに設定
lvStockList.View = view;
lvStockList.ItemsSource = list.Skip(1);
};
}
示例13: AddNewPanel
public Panel AddNewPanel()
{
ListView newLV = new ListView();
ComboBox newCB = new ComboBox();
panels.Add(new Panel(newCB, newLV));
newLV.Style = Resources["PanelListView"] as Style;
newLV.ItemContainerStyle = Resources["PanelListViewItem"] as Style; ;
GridView columns = new GridView();
columns.Columns.Add(AddGridViewColumn( "Name", "Name"));
columns.Columns.Add(AddGridViewColumn( "Type", "Extension"));
columns.Columns.Add(AddGridViewColumn( "Size", "Length"));
columns.Columns.Add(AddGridViewColumn( "Date of creation", "CreationTime"));
newLV.View = columns;
newLV.Loaded += PanelInitialized;
newCB.Style = Resources["DrivesComboBox"] as Style;
ColumnDefinition newColumn = new ColumnDefinition();
newColumn.Width = new GridLength(1, GridUnitType.Star);
PanelsGrid.ColumnDefinitions.Add(newColumn);
newLV.SetValue(Grid.RowProperty, 1);
newLV.SetValue(Grid.ColumnProperty, numOfPanels);
newCB.SetValue(Grid.RowProperty, 0);
newCB.SetValue(Grid.ColumnProperty, numOfPanels);
PanelsGrid.Children.Add(newLV);
PanelsGrid.Children.Add(newCB);
AddDrivesInComboBox(newCB);
newCB.SelectionChanged += DiskChanged;
return panels[numOfPanels++];
}
示例14: ViewPage
private void ViewPage(int page, int num)
{
DrawingsDataContext dc = DBCommon.NewDC;
IQueryable<Drawing> res = (from d in dc.Drawings select d).Skip((page - 1)*num).Take(num);
// Create the GridView
var gv = new GridView();
gv.AllowsColumnReorder = true;
// Create the GridView Columns
PropertyInfo[] pi = typeof (MPDrawing).GetProperties();
foreach (PropertyInfo p in pi)
{
var gvc = new GridViewColumn();
gvc.DisplayMemberBinding = new Binding(p.Name);
gvc.Header = p.Name;
gvc.Width = Double.NaN;
gv.Columns.Add(gvc);
}
listView1.View = gv;
listView1.ItemsSource = res;
}
示例15: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var config = value as ColumnConfig;
if (config != null)
{
var gridView = new GridView();
gridView.ColumnHeaderContainerStyle = Application.Current.FindResource("HeaderContainerStyle") as Style;
gridView.ColumnHeaderTemplate = Application.Current.FindResource("HeaderTemplate") as DataTemplate;
if (config.Columns != null)
{
foreach (var column in config.Columns)
{
var bindingDisplayMember = new Binding(column.DataField);
if (IsStripMultiLinesInList)
bindingDisplayMember.Converter = stripMultiLineConverter;
GridViewColumn gvc = new GridViewColumn { Header = column, DisplayMemberBinding = bindingDisplayMember };
var bindingWidth = new Binding("IsVisible");
bindingWidth.Source = column;
bindingWidth.Converter = this.columnIsVisibleToWidthConverter;
BindingOperations.SetBinding(gvc, GridViewColumn.WidthProperty, bindingWidth);
gvc.SetValue(GridViewSort.PropertyNameProperty, bindingDisplayMember.Path.Path);
gridView.Columns.Add(gvc);
}
}
return gridView;
}
return Binding.DoNothing;
}