У меня возникла проблема, когда я пытаюсь использовать список для отображения списка объектов и отправки их на новую страницу. Однако BrandBox.isSelected возвращает значение null.
.xaml
<Grid >
<ListView x:Name = "BrandBox" HorizontalAlignment = "Stretch" VerticalAlignment = "Top" SelectedItem = "{Binding ItemSelected, Mode=TwoWay}" SelectionChanged = "Selector_OnSelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate >
<DataTemplate>
<StackPanel Orientation = "Vertical" VerticalAlignment = "Stretch" HorizontalAlignment = "Stretch" Width = "128">
<Image Source = "{Binding BrandImageLoc}" HorizontalAlignment = "Stretch" VerticalAlignment = "Top" Stretch = "UniformToFill" />
<TextBlock Text = "{Binding BrandName}" HorizontalAlignment = "Stretch" VerticalAlignment = "Bottom" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
.cs
List<Brand> Brands = new List<Brand>();
public ManufactuerList()
{
InitializeComponent();
Brands = App.career.Brands;
this.BrandBox.ItemsSource = Brands;
}
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
Brand selectedBrand = BrandBox.SelectedItem as Brand;
this.NavigationService.Navigate(new CarsPurchaseable(selectedBrand));
}





Попробуйте сделать так
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListView brandBox = sender as ListView;
if (brandBox != null)
{
Brand selectedBrand = brandBox.SelectedItem as Brand;
if (selectedBrand != null)
{
this.NavigationService.Navigate(new CarsPurchaseable(selectedBrand));
}
}
}