I have to use a list.
I'm trying to add my searched data to the view list and it's crashing again and again.
i thing the issue is in list view Thank you.
Error:
System.Exception: 'Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))'
XML:
<ListView x:Name="listView" Grid.ColumnSpan="5" Grid.RowSpan="5" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Height="421" Width="711" Margin="0,93,0,0" Grid.Column="1">
<ListView.HeaderTemplate>
<DataTemplate>
<Grid Padding="12" Background="{ThemeResource SystemBaseLowColor}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Name" Style="{ThemeResource CaptionTextBlockStyle}"/>
<TextBlock Grid.Column="1" Text="Publisher" Style="{ThemeResource CaptionTextBlockStyle}"/>
<TextBlock Grid.Column="2" Text="PublishDate" Style="{ThemeResource CaptionTextBlockStyle}"/>
<TextBlock Grid.Column="3" Text="Quantity" Style="{ThemeResource CaptionTextBlockStyle}"/>
<TextBlock Grid.Column="4" Text="Category" Style="{ThemeResource CaptionTextBlockStyle}"/>
<TextBlock Grid.Column="5" Text="Price" Style="{ThemeResource CaptionTextBlockStyle}"/>
</Grid>
</DataTemplate>
</ListView.HeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate x:Name="TableDataTemplate">
<Grid Height="48" AutomationProperties.Name="{Binding Name}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="nameTbx" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Name}" />
<TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{Binding model.Publisher}"/>
<TextBlock Grid.Column="3" VerticalAlignment="Center" Text="{Binding model.PublishDate}"/>
<TextBlock Grid.Column="4" VerticalAlignment="Center" Text="{Binding model.Quantity}"/>
<TextBlock Grid.Column="5" VerticalAlignment="Center" Text="{Binding model.Category}"/>
<TextBlock Grid.Column="6" VerticalAlignment="Center" Text="{Binding model.Price}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
c#:
{
public MainPage()
{
this.InitializeComponent();
listView.ItemsSource = BookLib.ItemCollection.Items;
}
private void searchTbx_TextChanged(object sender, TextChangedEventArgs e)
{
var match = BookLib.ItemCollection.Items.Find(x => x.Name.ToLower() == searchTbx.Text.ToLower());
if (match != null)
{
listView.Items.Add(match.Name);
}
}
please help me to slove this issue