Hide NewItemPlaceHolder in ListBox WPF - c#

I have a problem with DataGrid and ListBox. Users can add new rows to datagrid, but an empty row is visible in listbox.
I found info about NewItemPlaceHolder, but I don't know how to hide it in listbox.
XAML:
<ListBox AlternationCount="2"
ItemContainerStyle="{StaticResource alternatingWithTriggers}"
x:Name="ViewListBox"
Background="AliceBlue"
ItemsSource="{Binding Converter={StaticResource IgnoreNewItemPlaceholderConverter}}" >
CS:
public static readonly IgnoreNewItemPlaceholderConverter Instance
= new IgnoreNewItemPlaceholderConverter();
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (value != null && value.ToString() == "{NewItemPlaceholder}")
{
return DependencyProperty.UnsetValue;
}
MessageBox.Show(value.ToString());
return value;
}

Create a new collection view (SelectsView) of Selects (ObservableCollection of SelectItem) and filter the view
SelectsView = new();
SelectsView.Source = Selects;
SelectsView.Filter += SelectsView_Filter;
SelectsListView.ItemsSource = SelectsView.View;
The view's filter
private void SelectsView_Filter(object sender, FilterEventArgs e)
{
// Hide NewItemPlaceHolder
if (e.Item is SelectItem)
{
e.Accepted = true;
}
else
{
e.Accepted = false;
}
}

Related

WPF ComboBox with CompositeCollection in Usercontrol does not work: SelectedIndex set to -1

I am using MVVM.
I have a CompositeCollection consisting of
ComboboxItem with 'Select a vendor' as content
CollectionContainer which is bounded
When I use the ComboBox XAML code directly in my view the SelectedIndex is set to 0 (as expected).
However, when I put the ComboBox XAML code in a Usercontrol and use the control in my view, the SelectedIndex is set to -1.
Any idea how to fix this issue, so that I can use the usercontrol?
All my bindings work.
Note:
when Combobox XAML code is directly in view: the ComboboxConverter sets the Vendor property to null when 'Select a vendor' is selected by the user.
However, when ComboBox XAML code is in a Usercontrol the code does not get in
if (comboboxItem.Content.ToString() == "Select a vendor")
{
//gets here when code is in view <-> code in control
return null;
}
ComboboxConverter
public class ComboboxConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var vendor = value as Vendor;
if (vendor != null)
{
return vendor;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var comboboxItem = value as ComboBoxItem;
if (comboboxItem != null)
{
if (comboboxItem.Content.ToString() == "Select a vendor")
{
//gets here when code is in view <-> code in control
return null;
}
return null;
}
var vendor = value as Vendor;
if (vendor != null)
{
return vendor;
}
return null;
}
}
VendorControl
<UserControl x:Class="Tool.Controls.VendorControl"
xmlns:local="clr-namespace:Tool.Controls"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:objects='clr-namespace:Tool.Objects'
xmlns:converters='clr-namespace:Tool.Converters'
mc:Ignorable="d" >
<UserControl.Resources>
<converters:ComboboxConverter x:Key='ComboboxConverter' />
</UserControl.Resources>
<Grid>
<ComboBox Name='cmbVendor'
SelectedItem='{Binding Vendor, Converter={StaticResource ComboboxConverter}, Mode=TwoWay}'
Grid.Column='1'
IsSynchronizedWithCurrentItem='True'>
<ComboBox.Resources>
<CollectionViewSource x:Key='VendorsCollection'
Source='{Binding Vendors}' />
<DataTemplate DataType='{x:Type objects:Vendor}'>
<StackPanel Orientation='Horizontal'>
<TextBlock Text='{Binding Name}' />
</StackPanel>
</DataTemplate>
</ComboBox.Resources>
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem Content='Select a vendor' />
<CollectionContainer Collection='{Binding Source={StaticResource VendorsCollection}}' />
</CompositeCollection>
</ComboBox.ItemsSource>
</ComboBox>
ViewModel
private void OnWindowLoaded()
{
LoadVendors();
}
ObservableCollection<Vendor> _vendors = new ObservableCollection<Vendor>();
public ObservableCollection<Vendor> Vendors
{
get
{
return _vendors;
}
}
private Vendor _vendor;
public Vendor Vendor
{
get
{
return _vendor;
}
set
{
if (value != _vendor)
{
_vendor = value;
RaisePropertyChanged(nameof(Vendor));
}
}
}
private void LoadVendors()
{
var dVendors = VendorHelper.GetVendors();
if (Vendors.Count > 0)
{
DispatcherHelper.CheckBeginInvokeOnUI(() => Vendors.Clear());
}
dVendors.ForEach(dV =>
{
var vendor = new Vendor(dV);
DispatcherHelper.CheckBeginInvokeOnUI(() => Vendors.Add(vendor));
});
}
At the beginning when your Vendor is null, function Convert will return null as well but your combobox does not know what null means, that's why it sets its selected index value to -1.
You can solve this by creating a behavior which will always select index 0 when it is set to -1.
public class SelectFirstItemBehavior : Behavior<ComboBox>
{
protected override void OnAttached()
{
AssociatedObject.SelectionChanged += AssociatedObject_SelectionChanged;
}
protected override void OnDetaching()
{
AssociatedObject.SelectionChanged -= AssociatedObject_SelectionChanged;
base.OnDetaching();
}
private void AssociatedObject_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var combobox = sender as ComboBox;
if (combobox != null && combobox.SelectedIndex == -1)
{
combobox.SelectedIndex = 0;
}
}
}
And then in your XAML part:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
...
inside your Combobox:
<i:Interaction.Behaviors>
<SelectFirstItemBehavior/>
</i:Interaction.Behaviors>

Binding ToggleButton IsChecked property to another ToggleButton not working

I have two ToggleButtons.
I need to bind one IsChecked property to the other ToggleButton.
I use a custom Converter to inverse the value.
However, it's not working? Here's my code:
XAML:
<ToggleButton
IsChecked="{Binding Path=ToggleButton.IsChecked, ElementName=menuCatUit,
Converter={StaticResource InvertBool}}"/>
<ToggleButton x:Name="menuCatUit" IsChecked="True" />
Code:
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");
return !(bool)value;
}
}
Remove the "ToggleButton" from the path property.
You only need the property name.
<ToggleButton
IsChecked="{Binding Path=IsChecked, ElementName=menuCatUit,
Converter={StaticResource InvertBool}}"/>
Here is what i Do, I send them all to the same Checked and UnChecked event:
privateToggleButton Toggle;
public void ToggleButtonChecked(object sender, RoutedEventArgs e)
{
if (Toggle != null && Toggle != sender as ToggleButton)
{
Toggle.IsChecked = false;
}
Toggle = sender as ToggleButton;
}
public void ToggleButtonUnChecked(object sender, RoutedEventArgs e)
{
if (Toggle != null)
{
Toggle = null;
}
}
And then to check which ToggleButton is checked do something like this
switch (Toggle.Name)
{
case ("Button1"): /*MyCode*/ break;
};
Found the solution:
I needed to edit my converter because ToggleButton uses a nullable bool.
[ValueConversion(typeof(bool?), typeof(bool))]
public class InverseNullableBool : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(bool?))
throw new InvalidOperationException("The target must be a nullable boolean");
bool? b = (bool?)value;
return !(b.HasValue && b.Value);
}
}

DataTemplate and WrapPanel visibility

I'm getting this error:
Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an
exception.
With xaml code:
<WrapPanel Orientation="Horizontal" Grid.Row="0" >
<WrapPanel.Visibility>
<Binding Path="setVisible" Converter="{StaticResource BooleanToVisibilityConverter}" ConverterParameter="{Binding setVisible}"/>
</WrapPanel.Visibility>
//textblocks goes here
</WrapPanel>
and class:
public class dataTemplate_xItem
{
(...)
public bool setVisible { get; set; }
public sealed class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var flag = false;
if (value is bool)
{
flag = (bool)value;
}
else if (value is bool?)
{
var nullable = (bool?)value;
flag = nullable.GetValueOrDefault();
}
if (parameter != null)
{
if (bool.Parse((string)parameter))
{
flag = !flag;
}
}
if (flag)
{
return Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var back = ((value is Visibility) && (((Visibility)value) == Visibility.Visible));
if (parameter != null)
{
if ((bool)parameter)
{
back = !back;
}
}
return back;
}
}
}
And before i'm adding item to ListView, checking
if(myValue != 0)
newItem.setVisible = true;
else
newItem.setVisible = false;
Any idea what goes wrong? :)
icebat is correct. The ConverterParameter is not a DependencyProperty and therefore, cannot be bound to. Looking at your xaml, you do not need the ConverterParameter. Nor do you need the extended markup for the binding expression. You xaml can simply be
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="Boolean2Visibility" />
</UserControl.Resources>
<WrapPanel Orientation="Horizontal" Grid.Row="0" Visibility="{Binding Path=setVisible, Converter={StaticResource Boolean2Visibility}}" />
This code assumes you are in a UserControl

Updating the source with multibinding

I have a combo box i.e editable. The combo box in my app acts like a editing control for all the datagrid cells i.e editing the value from the combo box should update the binding of my datagridtemplatecolumn. The below code updates the source if its a normal binding. If its a multibinding, it calls the convertback() function. I am using the below converter in order to update my source. The ParentID property is set to one way. I need to update only the ID property. Please help me with the convert back function
Xaml
<tk:Datagrid>
<tk:DataGridTemplateColumn Header="Event ID" MinWidth="100" CellTemplate="{StaticResource ClipsEventIDCellTemplate}" CellEditingTemplate="{StaticResource ClipsEventIDCellEditingTemplate}" />
</tk:Datagrid>
<DataTemplate x:Key="ClipsEventIDCellTemplate">
<TextBlock>
<TextBlock.Text>
<MultiBinding UpdateSourceTrigger="Explicit" Converter="{StaticResource EventIDConvert}" Mode="TwoWay" UpdateSourceTrigger="Explicit" >
<Binding Path="ParentID" Mode="OneWay"/>
<Binding Path="ID" Mode="TwoWay"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
<ComboBox x:Name="UniversalTextBox" IsEditable="True" ItemsSource="{Binding UniversalTextEntries, ElementName=TheMainWindow, Mode=OneWay}" KeyDown="OnUniversalTextKeyDown"/>
Code
// properties
public int ID
{
get { return m_id; }
set
{
if (m_id != value)
{
m_id = value;
NotifyPropertyChanged("ID");
}
}
}
public int ParentID
{
get;
set;
}
private void OnUniversalTextKeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Enter && e.Key != Key.Escape)
return;
var comboBox = sender as ComboBox;
if (comboBox == null)
return;
BindingExpression binding = null;
MultiBindingExpression multibinding = null;
bool restoreGridFocus = false;
bool isMultibinding = false;
binding = comboBox.GetBindingExpression(ComboBox.TextProperty);
if (binding == null)
{
isMultibinding = true;
multibinding = BindingOperations.GetMultiBindingExpression(comboBox, ComboBox.TextProperty);
if (multibinding == null && multibinding.BindingExpressions.Count < 0)
return;
}
if (e.Key == Key.Escape)
{
restoreGridFocus = true;
if (!isMultibinding)
binding.UpdateTarget();
else
multibinding.UpdateTarget();
}
else if (e.Key == Key.Enter)
{
PopulateTextEntries(comboBox.Text);
restoreGridFocus = true;
if (!isMultibinding)
binding.UpdateSource();
else
multibinding.UpdateSource();
}
if (restoreGridFocus)// set the focus back to the lastfocuced cell in the datagrid
{
e.Handled = true;
if (m_BoundDataGrid != null)
{
var cell = m_BoundDataGridCell;
if (cell == null)
cell = DataGridUtils.GetCell(m_BoundDataGrid, m_BoundObject, m_BoundColumnIndex);
if (cell != null)
cell.Focus();
}
}
}
Converter
public class EventIDConverter : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length < 2)
return null;
return string.Format("{0}{1}", values[0], values[1]);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
if (value == null)
return null;
//ToDo
???????????????
}
#endregion
}
Create a Converter inherited from IMultiValueConverter.
Get the TextBlock.Texts value from the Convert method instead of the StringFormat and implement the ConvertBack to set the sources.
public class EventIDConverter : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length < 2)
return null;
return string.Format("{0} {1}", values[0], values[1]);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
if (value == null)
return null;
string[] splitValues = ((string)value).Split(' ');
return splitValues;
}
#endregion
}
Note:
I put a space to separate the two value. This is for the split method in the ConvertBack.
You set one of the bindings to OneWay

Change background color of ListView row programmatically (wpf)

I have a class that populates a ListView by passing a list of objects. The class uses reflection to see the properties of each object in order to generate the ListView. How could I change the background color of a row in the ListView.
This page does exactly what I am looking for. The only problem is that my ListView is bound to the list of objects. In other words each item of the ListView is an object that is bound instead of a ListViewItem. I am assuming that is the reason why I cannot cast some item in the ListView to a ListViewItem. For example when I do this:
ListViewItem someItem = (ListViewItem)listView1.Items[0];
I get an InvalidcastException because if I where to physically add the objects to the ListView like:
listview.items.add(someObject) then this will work, but because I am binding the list to the ListView that line does not work. I think that is the reason why I am not able to cast. The reason why I want to cast it is becasue a ListViewItem has a Background property.
EDIT
I am able to do that with the first 12 objects I have tried the folowing:
for (int i = 0; i < listView1.Items.Count; i++)
{
var lvitem = listView1.ItemContainerGenerator.ContainerFromIndex(i) as ListViewItem;
lvitem.Foreground = Brushes.Green;
}
and I get this error:
and I also have tried this:
foreach (Tiro t in listView1.Items)
{
var lvitem = listView1.ItemContainerGenerator.ContainerFromItem(t) as ListViewItem;
if (t.numero == 0 || t.numero == 37)
{
//lvitem.Background = Brushes.Green;
lvitem.Foreground = Brushes.Green;
}
else if (t.numero % 2 == 0)
{
//lvitem.Background = Brushes.Red;
lvitem.Foreground = Brushes.Red;
}
else
{
//lvitem.Background = Brushes.Gray;
lvitem.Foreground = Brushes.Black;
}
}
and I get the same error:
I don't understand why lvitem is null after the 12 iteration?
It only works with the items that are being displayed....
You need to introduce ViewModels instead of shredding the WPF UI. e.g. I could create one as follows
public class ItemVM : INotifyPropertyChanged // if you want runtime changes to be reflected in the UI
{
public string Text {... raise property change in setter }
public Color BackgroundColor {... ditto... }
}
Next create a list of such objects as a property in your DataContext so that your ListView can bind to it.
// e.g. MainWindow
public IEnumerable<ItemVM> Items { get; set; }
Now all you need to do is bind your ListView to this collection and wire up the DataContext of the UI properly
<ListView x:Name="MyListView" ItemsSource="{Binding Items}" HorizontalContentAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}">
<TextBlock.Background>
<SolidColorBrush Color="{Binding BackgroundColor}"/>
</TextBlock.Background>
</TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Click="Button_Click" Content="Go PaleGreen"/>
Now changing the background color is easy. Just set the property of the corresponding ItemVM object to the Color you want. e.g. to set all items to go PaleGreen
private void Button_Click(object sender, RoutedEventArgs e)
{
foreach (var item in Items)
item.BackgroundColor = Colors.PaleGreen;
}
You could use the ItemContainerGenerator, e.g:
var lvitem = listView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;
var lvitem = listView.ItemContainerGenerator.ContainerFromIndex(0) as ListViewItem;
However by default the ListView is virtualizing, this means ListViewItems are created on the fly as needed (only if the item is actually visible in the list), so the above methods will not return containers for items which are currently not visible.
This being the case it usually is preferable to define a binding on the Background property via a Setter in the ItemContainerStyle.
When using the ItemContainerGenerator then be aware that the containers are generated asynchronously. The generator exposes a status changed event you could listen to:
listView.ItemContainerGenerator.StatusChanged += new EventHandler(ContainerStatusChanged);
private void ContainerStatusChanged(object sender, EventArgs e)
{
if (listView.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
foreach (Tiro t in listView1.Items)
{
...
}
}
}
Not sure if that will create any weird drawing effects (flickering) or not.
Another option instead of building the listview items in code is to you use data templates. You might have to add a few properties to your view model for display purposes though.
Assuming the items in your ListBox are of type Foo, and in the ListBox you will display Foo.ItemInfo for each Foo item, and finally let's say there's a property called Status that determines how you want each Foo.ItemInfo to be displayed in the ListBox with respect to the background, foreground, font style, and tooltip text. Based on these requirements, add the following in your XAML:
<ListBox FontFamily="Courier New"
HorizontalAlignment="Left"
...
...other ListBox attributes...
...
<ListBox.Resources>
<local:BGConverter x:Key="BackgroundConverter"/>
<local:FGConverter x:Key="ForegroundConverter"/>
<local:FSConverter x:Key="FontStyleConverter"/>
<local:TTConverter x:Key="ToolTipConverter"/>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ItemInfo}"
Background="{Binding Converter={StaticResource BackgroundConverter}}"
FontStyle="{Binding Converter={StaticResource FontStyleConverter}}"
Foreground="{Binding Converter={StaticResource ForegroundConverter}}"
ToolTip="{Binding Converter={StaticResource ToolTipConverter}}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Next, add the following into your MainWindow.xaml.cs (or whatever you've named the XAML's accompanying file) in C#:
public class BGConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Foo foo = (Foo)value;
string bgColor = "Gray";
switch(foo.Status)
{
case 0:
bgColor = "White";
break;
case 1:
bgColor = "Cyan";
break;
case 2:
bgColor = "Yellow";
break;
}
return bgColor;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FSConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Foo foo = (Foo)value;
string fStyle = "Normal";
switch(foo.Status)
{
case 0:
fStyle = "Normal";
break;
case 1:
fStyle = "Oblique";
break;
case 2:
fStyle = "Italic";
break;
}
return fStyle;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FGConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Foo foo = (Foo)value;
string fgColor = "Black";
switch(foo.Status)
{
case 0:
fgColor = "Blue";
break;
case 1:
fgColor = "Brown";
break;
case 2:
fgColor = "DarkBlue";
break;
}
return fgColor;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class TTipConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Foo foo = (Foo)value;
string ttText = "No tool tips for this item.";
switch(foo.Status)
{
case 0:
ttText = "The item has not been processed";
break;
case 1:
ttText = "The item has been processed but not saved";
break;
case 2:
ttText = "The item has been processed and saved";
break;
}
return ttText ;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
This is one way I've found that works...there's no doubt many other ways, and your mileage may vary...
In any event, HTH
After some googling i found out my own solution
I am using Listview.ItemsSource and as source i use List
Then i can set background of specify ListViewItem in List, and just refresh listview.
XAML:
<ListView x:Name="listView" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.Row="1">
<ListView.View>
<GridView>
<GridViewColumn Header="IP" DisplayMemberBinding="{Binding IP}" Width="Auto"/>
<GridViewColumn Header="PING" DisplayMemberBinding="{Binding Ping}" Width="Auto"/>
<GridViewColumn Header="Host Name" DisplayMemberBinding="{Binding DNS}" Width="Auto"/>
<GridViewColumn Header="Mac" DisplayMemberBinding="{Binding MAC}" Width="Auto"/>
<GridViewColumn Header="Výrobce" DisplayMemberBinding="{Binding Manufacturer}" Width="Auto"/>
</GridView>
</ListView.View>
</ListView>
Fill ListView with Items with Gray Background:
List<ListViewItem> ITEMS = new List<ListViewItem>();
private void button_Click(object sender, RoutedEventArgs e)
{
for (int i = 1; i < 20; i++)
{
ListViewItem OneItem = new ListViewItem();
OneItem.Background = Brushes.LightGray;
OneItem.Content = new Device() { IP = "1.1.1.1", Ping = "30ms", DNS = "XYZ", MAC = "2F:3C:5F:41:F9", Manufacturer = "Intel" };
ITEMS.Add(OneItem);
listView.ItemsSource = ITEMS;
}
listView.Items.Refresh();
}
public class Device
{
public string IP { get; set; }
public string Ping { get; set; }
public string DNS { get; set; }
public string MAC { get; set; }
public string Manufacturer { get; set; }
}
Create Method for Row Change Color:
private void ChangeRowColor(int RowIndex,SolidColorBrush NewBackground)
{
ITEMS[RowIndex].Background = NewBackground;
listView.Items.Refresh();
}
And use it:
private void button1_Click(object sender, RoutedEventArgs e)
{
ChangeRowColor(4, Brushes.Green);
}
List<ListViewItem> ITEMS = new List<ListViewItem>();
private void loadListView(ListView lv)
{
int numberOfRows = 20;
string[] student_number, first_name, last_name, middle_name, extension, course, year, section;
// ...... Assign values to the arrays above...
for (int h = 0; h <= numberOfRows - 1; h++)
{
ListViewItem OneItem = new ListViewItem();
OneItem.Background = course[h] == "Grade" ? Brushes.Red : Brushes.Transparent; //Decide the color of the Row
OneItem.Content = new Student
{
Student_Number = student_number[h],
Course = course[h],
Section = section[h],
Year = year[h],
FullName = first_name[h] + " " + middle_name[h] + ". " + last_name[h] + " " + extension[h]
};
ITEMS.Add(OneItem);
lv.ItemsSource = ITEMS;
}
lv.Items.Refresh();
}
public class Student
{
public string Student_Number { get; set; }
public string FullName { get; set; }
public string Course { get; set; }
public string Section { get; set; }
public string Year { get; set; }
}
output screenshot

Categories

Resources