本文整理汇总了C#中System.Windows.Controls.ListViewItem类的典型用法代码示例。如果您正苦于以下问题:C# ListViewItem类的具体用法?C# ListViewItem怎么用?C# ListViewItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListViewItem类属于System.Windows.Controls命名空间,在下文中一共展示了ListViewItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateListView
public void UpdateListView()
{
Process[] Processes = Process.GetProcesses();
// Array.Sort(Processes, new CompareProcessStartTime());
var sorted = from p in Processes orderby StartTimeNoException(p) descending, p.Id select p;
foreach (Process p in sorted)
{
ProcessModule pm;
string path;
try { pm = p.MainModule; }
catch (Exception) { continue; }
try { path = pm.FileName; }
catch (Exception) { continue; }
if (p.ProcessName == "svchost") continue;
ListViewItem lvi = new ListViewItem() {Tag=p };
StackPanel sp = new StackPanel() { Width = 64, Height = 64 };
Image i = new Image() { Source = GetAssociatedIcon(path), Width = 32, Height = 32 };
TextBlock tb = new TextBlock()
{
TextWrapping = System.Windows.TextWrapping.Wrap,
MaxWidth = sp.Width,
Text = p.ProcessName,
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
VerticalAlignment = System.Windows.VerticalAlignment.Top,
TextAlignment = TextAlignment.Center
};
sp.Children.Add(i);
sp.Children.Add(tb);
lvi.Content = sp;
lv.Items.Add(lvi);
}
}
示例2: bindingArry
private void bindingArry(string[][] source)
{
Brush blackBrush = new SolidColorBrush(Colors.Black);
Brush grayBrush = new SolidColorBrush(Colors.LightBlue);
Thickness borderThickness = new Thickness(1);
foreach (string[] line in source)
{
ListViewItem lvi = new ListViewItem();
StackPanel sp = new StackPanel();
sp.Orientation = Orientation.Horizontal;
foreach (string item in line)
{
Label itemLabel = new Label();
itemLabel.Background = grayBrush;
itemLabel.BorderBrush = blackBrush;
itemLabel.BorderThickness = borderThickness;
itemLabel.Content = item;
sp.Children.Add(itemLabel);
}
lvi.Content = sp;
lvTable.Items.Add(lvi);
}
}
示例3: SubmitEditBtn_Click
private void SubmitEditBtn_Click(object sender, RoutedEventArgs e)
{
Spell currSpell = shared.currentSpell != null ? shared.currentSpell : new Spell();
if (SpellNameEditTxtBx.Text != currSpell.SpellName && currSpell == shared.currentSpell)
{
currSpell.SpellName = SpellNameEditTxtBx.Text;
shared.spellListView.Items.Clear();
foreach (Spell spell in shared.character.spells) {
ListViewItem newItem = new ListViewItem();
newItem.Content = spell.SpellName;
shared.spellListView.Items.Add(newItem);
}
}
else {
currSpell.SpellName = SpellNameEditTxtBx.Text;
}
currSpell.Rank = Convert.ToInt32(RankEditTxtBx.Text);
currSpell.Description = DescriptionEditTxtBx.Text;
currSpell.Requirement = ReqEditTxtBx.Text;
currSpell.Area = AreaEditTxtBx.Text;
currSpell.Duration = DurationEditTxtBx.Text;
if (currSpell != shared.currentSpell)
{
currSpell.Casts = 0;
shared.character.spells.Add(currSpell);
ListViewItem newItem = new ListViewItem();
newItem.Content = currSpell.SpellName;
shared.spellListView.Items.Add(newItem);
}
shared.currentSpell = currSpell;
this.Close();
}
示例4: AddDependency
void AddDependency(object pSender, RoutedEventArgs pEvents)
{
var lDialog = new Microsoft.Win32.OpenFileDialog()
{
Title = "Choose dependency Assembly",
CheckFileExists = true,
Filter = "Assemblies|*.dll;*.exe;*.winmd|All Files|*.*",
Multiselect = true
};
if (lDialog.ShowDialog() == true)
{
foreach (string lName in lDialog.FileNames)
{
// Check if the dependency is already on the list.
var lSameLib = (
from ListViewItem lItem in DependencyList.Items
where lItem.Content.Equals(lName)
select lItem);
if (lSameLib.Count() == 0)
{
ListViewItem lEntry = new ListViewItem();
lEntry.Content = lName;
DependencyList.Items.Add(lEntry);
}
}
}
}
示例5: AddList
private void AddList(Data.BOKhachHang item)
{
ListViewItem li = new ListViewItem();
li.Content = item;
li.Tag = item;
lvData.Items.Add(li);
}
示例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: Bookmark
public Bookmark(KinectBrowser.D3D.Browser.D3DBrowser browser)
{
this.InitializeComponent();
currentBrowser = browser;
xmlPath = Directory.GetParent(Environment.CurrentDirectory)+"\\KinectBrowser\\bookmark.xml";
xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
XmlNodeList bookmarkList = xmlDoc.GetElementsByTagName("Bookmark");
foreach (XmlNode node in bookmarkList)
{
XmlElement bookmarkElement = (XmlElement) node;
string title = bookmarkElement.GetElementsByTagName("Title")[0].InnerText;
string url = bookmarkElement.GetElementsByTagName("Url")[0].InnerText;
ListViewItem item = new ListViewItem();
item.Content = title;
item.ToolTip = url;
item.Selected += new RoutedEventHandler(Select_bookmark);
//item.MouseDoubleClick += new MouseButtonEventHandler(Bookmark_DoubleClick);
listView1.Items.Add(item);
}
}
示例8: Bookmark
public Bookmark(WebBrowser webBrowser)
{
this.InitializeComponent();
wb = webBrowser;
xmlPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName+"\\bookmark.xml";
xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
XmlNodeList bookmarkList = xmlDoc.GetElementsByTagName("Bookmark");
foreach (XmlNode node in bookmarkList)
{
XmlElement bookmarkElement = (XmlElement) node;
string title = bookmarkElement.GetElementsByTagName("Title")[0].InnerText;
string url = bookmarkElement.GetElementsByTagName("Url")[0].InnerText;
ListViewItem item = new ListViewItem();
item.Content = title;
item.ToolTip = url;
item.Selected += new RoutedEventHandler(Select_bookmark);
listView1.Items.Add(item);
}
}
示例9: DragList_DragOver
private void DragList_DragOver(object sender, DragEventArgs e)
{
_overTarget = ((DependencyObject)e.OriginalSource).FindAnchestor<ListViewItem>();
if (_overTarget == null) return;
if (_draggedItem == _overTarget) return;
(_overTarget.Content as AssetViewModel).DragOverTarget = true;
}
示例10: RefreshPlaylist
public void RefreshPlaylist(Playlist playlist)
{
Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() =>
{
_playlist = playlist;
listViewPlaylist.Items.Clear();
listViewPlaylistAlbumArt.Items.Clear();
string currentAlbum = string.Empty;
int songCount = 0;
foreach (var item in _playlist.Items)
{
// Add only one row per album (to do: expose row height in viewmodel)
songCount++;
string album = string.Format("{0}_{1}", item.AudioFile.ArtistName, item.AudioFile.AlbumTitle).ToUpper();
if (string.IsNullOrEmpty(currentAlbum))
{
currentAlbum = album;
}
else if (album != currentAlbum)
{
//Console.WriteLine("PlaylistWindow - RefreshPlaylists - Album: {0} SongCount: {1}", album, songCount);
var listViewItem = new ListViewItem();
listViewItem.Background = new LinearGradientBrush(Colors.HotPink, Colors.Yellow, 90);
listViewItem.Height = (songCount - 1) * 24;
listViewItem.Content = string.Format("{0}/{1}", (songCount - 1), currentAlbum);
listViewPlaylistAlbumArt.Items.Add(listViewItem);
currentAlbum = album;
songCount = 1;
}
listViewPlaylist.Items.Add(item);
}
}));
}
示例11: PrepareItem
protected override void PrepareItem(ListViewItem item)
{
if (_autoWidthColumns == null)
{
_autoWidthColumns = new HashSet<int>();
foreach (var column in Columns)
{
if(double.IsNaN(column.Width))
_autoWidthColumns.Add(column.GetHashCode());
}
}
foreach (var column in Columns)
{
if (_autoWidthColumns.Contains(column.GetHashCode()))
{
if (double.IsNaN(column.Width))
column.Width = column.ActualWidth;
column.Width = double.NaN;
}
}
base.PrepareItem(item);
}
示例12: CaseViewer
public CaseViewer()
{
InitializeComponent();
MyData md = new MyData();
md.CaseName = "dddd";
string[] row = { "1", "case1", "case1", "case1", "case1" };
ListViewItem ldv = new ListViewItem();
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = false;
doc.Load("record.xml");
XmlNode root = doc.DocumentElement;
XmlNodeList nodes = root.SelectNodes("Child");
foreach (XmlNode node in nodes)
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine(node.ChildNodes[i].InnerText);
}
MyData item = new MyData
{
CaseNumber = node.ChildNodes[0].InnerText.ToString(),
CaseName = node.ChildNodes[1].InnerText.ToString(),
CaseNotes = node.ChildNodes[2].InnerText.ToString(),
LastUpdatedBy = node.ChildNodes[3].InnerText.ToString(),
LastUpdateDate = node.ChildNodes[4].InnerText.ToString()
};
lstvu1.Items.Add(item);
}
}
示例13: AddList
private void AddList(Data.BOMenuKichThuocMon item)
{
ListViewItem li = new ListViewItem();
li.Content = item;
li.Tag = item;
lvData.Items.Add(li);
}
示例14: SPDefinitionWindow
public SPDefinitionWindow()
{
InitializeComponent();
def = Program.Configs[Program.SelectedConfig].GetSMDef();
if (def == null)
{
MessageBox.Show("The config was not able to parse a sourcepawn definiton.", "Stop", MessageBoxButton.OK, MessageBoxImage.Warning);
this.Close();
return;
}
List<SPDefEntry> defList = new List<SPDefEntry>();
for (int i = 0; i < def.Functions.Length; ++i) { defList.Add((SPDefEntry)def.Functions[i]); }
for (int i = 0; i < def.Constants.Length; ++i) { defList.Add(new SPDefEntry() { Name = def.Constants[i], Entry = "Constant" }); }
for (int i = 0; i < def.Types.Length; ++i) { defList.Add(new SPDefEntry() { Name = def.Types[i], Entry = "Type" }); }
for (int i = 0; i < def.MethodNames.Length; ++i) { defList.Add(new SPDefEntry() { Name = def.MethodNames[i], Entry = "Method" }); }
for (int i = 0; i < def.Properties.Length; ++i) { defList.Add(new SPDefEntry() { Name = def.Properties[i], Entry = "Property" }); }
defList.Sort((a, b) => { return string.Compare(a.Name, b.Name); });
defArray = defList.ToArray();
int defArrayLength = defArray.Length;
items = new ListViewItem[defArrayLength];
for (int i = 0; i < defArrayLength; ++i)
{
items[i] = new ListViewItem() { Content = defArray[i].Name, Tag = defArray[i].Entry };
SPBox.Items.Add(items[i]);
}
searchTimer.Elapsed += searchTimer_Elapsed;
}
示例15: LoadData
public void LoadData(List<Group> groups)
{
listView.Items.Clear();
foreach (TreeViewItem item in treeView.Items)
{
item.UnregisterName(item.Header.ToString());
}
treeView.Items.Clear();
foreach (Group group in groups)
{
TreeViewItem treeViewItem = new TreeViewItem() { Header = group.Name, Tag = group };
treeView.Items.Add(treeViewItem);
treeViewItem.RegisterName(group.Name, treeViewItem);
var persons = group.Persons;
foreach (Person person in persons)
{
ListViewItem listViewItem = new ListViewItem() { Content = person, Tag = person };
listView.Items.Add(listViewItem);
TreeViewItem i = treeView.FindName(group.Name) as TreeViewItem;
TreeViewItem treeViewSubItem = new TreeViewItem() { Header = person.Name, Tag = person };
i.Items.Add(treeViewSubItem);
}
treeViewItem.IsExpanded = true;
}
}