[Unity] Crashes when using <ListView>
Hi,
the usage of a <ListView> within our xaml files results in a NoesisGUI exception / an Unity3D crash. I created a new project which only contains Noesis and one xaml file.
Unity x86 5.3.5 p1 | Windows 8.1 pro x64 -> crash exception (dump files attached)
Unity 5.3.4 f1 | Mac 10.11.4 -> UnityEditor crashes
Noesis 1.2.6 f2 / f3
XAML:
works fine but:
results in the described behaviour. I also tried a non-empty ListView but it still leads to the same result.
Is there anything to keep in mind when working with <ListView>?
Best regards,
Michael
the usage of a <ListView> within our xaml files results in a NoesisGUI exception / an Unity3D crash. I created a new project which only contains Noesis and one xaml file.
Unity x86 5.3.5 p1 | Windows 8.1 pro x64 -> crash exception (dump files attached)
Unity 5.3.4 f1 | Mac 10.11.4 -> UnityEditor crashes
Noesis 1.2.6 f2 / f3
XAML:
Code: Select all
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Rectangle Fill="orange" Height="100" Width="100" />
<Rectangle Fill="green" Height="50" Width="50" />
</Grid>
Code: Select all
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Rectangle Fill="orange" Height="100" Width="100" />
<Rectangle Fill="green" Height="50" Width="50" />
<ListView />
</Grid>
Is there anything to keep in mind when working with <ListView>?
Best regards,
Michael
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: [Unity] Crashes when using <ListView>
Hi,
I was able to reproduce the crash. It happens when you don't provide a View for the ListView.
You should provide one until we fix this bug:
I was able to reproduce the crash. It happens when you don't provide a View for the ListView.
You should provide one until we fix this bug:
Code: Select all
<ListView ...>
<ListView.View>
<GridView>
<GridViewColumn .../>
...
</GridView>
</ListView.View>
</ListView>
Re: [Unity] Crashes when using <ListView>
Thx for your help! I'm meanwhile using an ItemsControl which works perfectly fine
Re: [Unity] Crashes when using <ListView>
Hi,
we reached a point where we need to use a ListView to display data instead of an ItemsControl. Unfortunately the ListView control doesn't work at the moment when no View is provided (no entries). As a result of the design / layout a GridView isn't an option.
We are using Noesis 1.2.6f4.
This is the code I used for testing:
CS:
XAML:
If the <ListView.View> ... </ListView.View> entry is removed the ListView isn't populated anymore.
Is this problem something that can be fixed in the near future? Or will the fix be part of a later release? / Is there any valid workaround?
we reached a point where we need to use a ListView to display data instead of an ItemsControl. Unfortunately the ListView control doesn't work at the moment when no View is provided (no entries). As a result of the design / layout a GridView isn't an option.
We are using Noesis 1.2.6f4.
This is the code I used for testing:
CS:
Code: Select all
using System.Collections.Generic;
using Noesis;
using UnityEngine;
public class User
{
public string Name { get; set; }
public int Age { get; set; }
}
public class ListViewDemo : MonoBehaviour
{
Grid root;
ListView lv;
void Start()
{
List<User> items = new List<User>();
items.Add(new User() { Name = "John Doe", Age = 42 });
items.Add(new User() { Name = "Jane Doe", Age = 39 });
items.Add(new User() { Name = "Sammy Doe", Age = 13 });
NoesisGUIPanel noesis = FindObjectOfType<NoesisGUIPanel>();
root = noesis.GetContent() as Grid;
if (root == null)
return;
lv = root.FindName("lvData") as ListView;
if (lv == null)
return;
lv.ItemsSource = items;
}
}
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ListView x:Name="lvData">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="120" DisplayMemberBinding="{Binding Name}" />
</GridView>
</ListView.View>
<ListView.ItemTemplate>
<DataTemplate>
<WrapPanel>
<TextBlock Text="Name: " />
<TextBlock Text="{Binding Name}" />
<TextBlock Text=", " />
<TextBlock Text="Age: " />
<TextBlock Text="{Binding Age}" />
</WrapPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
Is this problem something that can be fixed in the near future? Or will the fix be part of a later release? / Is there any valid workaround?
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: [Unity] Crashes when using <ListView>
Hi,
Right now the ListView requires a View (a GridView in particular) to specify the columns. This GridView describes how many columns are going to be shown for each item, and what property will be bound in the column.
Without a View the ListView doesn't have much sense, and maybe a ListBox is a better option.
If you want to simulate a ListBox using a ListView, you can define just one column, and bind the whole item. This is what we will do in the future when no View is specified:
Right now the ListView requires a View (a GridView in particular) to specify the columns. This GridView describes how many columns are going to be shown for each item, and what property will be bound in the column.
Without a View the ListView doesn't have much sense, and maybe a ListBox is a better option.
If you want to simulate a ListBox using a ListView, you can define just one column, and bind the whole item. This is what we will do in the future when no View is specified:
Code: Select all
<ListView ItemsSource="{Binding Users}">
<ListView.View>
<GridView>
<GridViewColumn Header="" DisplayMemberBinding="{Binding}" />
</GridView>
</ListView.View>
</ListView>