本文整理汇总了C#中Windows.UI.Xaml.Controls.ListViewItem类的典型用法代码示例。如果您正苦于以下问题:C# ListViewItem类的具体用法?C# ListViewItem怎么用?C# ListViewItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListViewItem类属于Windows.UI.Xaml.Controls命名空间,在下文中一共展示了ListViewItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEntry
public void AddEntry(Transaction ta)
{
ListViewItem entry = new ListViewItem();
entry.Content = ta.TypeName;
this.ItemList.Items.Add(entry);
this.taBinding.Add(ta.TypeName, ta);
}
示例2: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (App.CardList.Count > 0 && CardListView.Items.Count == 0) // cards were loaded from local storage on load and need to be added to the ListView
{
foreach (Card item in App.CardList)
{
CardListView.Items.Add(item);
}
}
else if (App.CardList.Count == 0 && CardListView.Items.Count == 0) // there are no cards saved yet
{
ListViewItem lvi = new ListViewItem();
lvi.FontSize = 20;
lvi.Content = "No Cards Saved Yet";
CardListView.Items.Add(lvi);
}
// a new card has just been scanned or entered manually, update the ListView
else if ((((ListViewItem)CardListView.Items[0]).Content.ToString() == "No Cards Saved Yet" && App.CardList.Count == CardListView.Items.Count) || App.CardList.Count > CardListView.Items.Count)
{
CardListView.Items.Clear();
foreach (Card item in App.CardList)
{
CardListView.Items.Add(item);
}
}
// disallow navigating backwards from MainPage to previous paths...all roads lead to/from MainPage
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.BackStack.Clear();
}
示例3: SetSelectedItem
/// <summary>
/// Mark the <paramref name="item"/> as selected and ensures everything else is not.
/// If the <paramref name="item"/> is null then everything is unselected.
/// </summary>
/// <param name="item"></param>
public void SetSelectedItem(ListViewItem item)
{
int index = -1;
if (item != null)
{
index = this.IndexFromContainer(item);
}
for (int i = 0; i < this.Items.Count; i++)
{
var lvi = (ListViewItem)this.ContainerFromIndex(i);
if (lvi != null)
{
if (i != index)
{
lvi.IsSelected = false;
}
else if (i == index)
{
lvi.IsSelected = true;
}
}
}
}
示例4: buttonAddPerson_Click
private async void buttonAddPerson_Click(object sender, RoutedEventArgs e)
{
var dialog = new ContentDialog();
dialog.Title = "Add a person to your list";
dialog.Content = new TextBox();
dialog.PrimaryButtonText = "Add";
dialog.IsPrimaryButtonEnabled = true;
var result = await dialog.ShowAsync();
if (ContentDialogResult.Primary == result)
{
try
{
var textBox = (TextBox)dialog.Content;
string text = textBox.Text;
if (text != "")
{
Person person = new Person(text);
ListViewItem item = new ListViewItem
{
Content = person.Name,
Tag = person
};
listViewPerson.Items.Add(item);
person.Save();
}
}
catch (NullReferenceException)
{
}
}
}
示例5: SetSelectedItem
/// <summary>
/// Mark the <paramref name="item" /> as selected and ensures everything else is not.
/// If the <paramref name="item" /> is null then everything is unselected.
/// </summary>
/// <param name="item"></param>
public void SetSelectedItem(ListViewItem item)
{
if (Items == null) return;
var index = -1;
if (item != null)
{
index = IndexFromContainer(item);
}
for (var i = 0; i < Items.Count; i++)
{
var lvi = (ListViewItem) ContainerFromIndex(i);
if (lvi == null) continue;
if (i != index)
{
lvi.IsSelected = false;
}
else if (i == index)
{
lvi.IsSelected = true;
}
}
}
示例6: ItemInvoked
private void ItemInvoked(ListViewItem obj)
{
var menuItem = obj?.Content as SplitViewPaneMenuItem;
if (menuItem != null)
{
this.NavigationService.Navigate(menuItem.AssociatedPage, menuItem.Parameters);
}
}
示例7: GenerateMatchList
void GenerateMatchList()
{
MatchList.Items.Clear();
foreach (Match m in bracket.Matches)
{
ListViewItem temp = new ListViewItem();
temp.Content = m.ToString();
MatchList.Items.Add(temp);
}
}
示例8: writeToList
public void writeToList(ListView listView, ListViewItem itm)
{
foreach (var line in File.ReadLines(fileName))
{
itm = new ListViewItem();
itm.FontFamily = font;
itm.Content = line;
listView.Items.Add(itm);
}
}
示例9: GenerateMatchList
void GenerateMatchList()
{
MatchList.Items.Clear();
for (int i = bracket.CurrentMatch; i < bracket.MatchCount; i++)
{
ListViewItem temp = new ListViewItem();
temp.Content = bracket.Matches[i].ToString();
MatchList.Items.Add(temp);
}
}
示例10: button_Click
private void button_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(textBox.Text))
{
text = textBox.Text;
itm = new ListViewItem();
itm.FontFamily = font;
itm.Content = text;
listView.Items.Add(itm);
fh.writeToFile(text);
textBox.Text = empty;
}
}
示例11: GenerateLeaderboard
void GenerateLeaderboard()
{
Leaderboard.Items.Clear();
foreach (Player p in bracket.Players)
{
ListViewItem temp = new ListViewItem();
temp.FontFamily = font;
temp.Content = p.ToString();
Leaderboard.Items.Add(temp);
}
}
示例12: NavMenuList_ItemInvoked
private void NavMenuList_ItemInvoked(object sender, ListViewItem listViewItem)
{
var item = (NavMenuItem)((NavMenuListView)sender).ItemFromContainer(listViewItem);
if (item != null)
{
if (item.DestPage != null &&
item.DestPage != this.Frame.CurrentSourcePageType)
{
this.Frame.Navigate(item.DestPage, item.Arguments);
}
}
}
示例13: SetSelectedItem
public void SetSelectedItem(ListViewItem item)
{
if (Items == null)
return;
foreach (
var cont in
Items.Select(i => (ListViewItem) ContainerFromItem(i)).Where(cont => cont != null && cont != item))
{
cont.IsSelected = false;
}
if (item != null)
item.IsSelected = true;
}
示例14: MainPage
public MainPage()
{
this.InitializeComponent();
var db = new SQLiteConnection(new SQLitePlatformWinRT(), Path.Combine(ApplicationData.Current.LocalFolder.Path, "Storage.sqlite"));
if (!db.TableMappings.Any()) db.CreateTable<Person>();
List<Person> people = (from p in db.Table<Person>() select p).ToList();
foreach (var person in people)
{
ListViewItem item = new ListViewItem();
item.Content = person.Name;
item.Tag = person;
listViewPerson.Items.Add(item);
}
}
示例15: UpdateList
private void UpdateList()
{
Items.Clear();
foreach (var group in ItemsSource)
{
var headerViewItem = new ListViewItem { Content = group, ContentTemplate = GroupHeaderTemplate, Tag = this };
Items.Add(headerViewItem);
foreach (var item in (IEnumerable)group)
{
var viewItem = new ListViewItem { Content = item, ContentTemplate = ItemTemplate };
Items.Add(viewItem);
}
}
}