I only notice the issues on Windows, as that is currently my target platform.
I found a way to circumvent the issue, by setting the 'hidden' listview's opacity to 0. It feels like cheating but it causes both listviews to render but only one to be visible.
The scrollview i use to programmatically scroll to the latest item added, as the ListView's ScrollTo method is working weirdly for me.
Anyhow, thanks for you response!
Setting ListView to visible causes app to crash
Hi there,
I am experiencing some issues with my maui app. I have a page within my app which has two listviews. Only one listview is visible at a time, which i do by setting the IsVisible property to true or false. Upon setting the 'hidden' listview's IsVisible property to true, I suppose the app tries to fetch its itemssource binding data, upon which the application freezes or becomes extremely slow.
I have bound both listviews to an observablecollection, which to my knowledge should be the best performing option. How can I optimize my app to stop freezing and keep it running smoothly? View my code below. Thanks in advance!
<Grid RowDefinitions="*,5,40" ColumnDefinitions="75,75,75,105,*">
<ScrollView x:Name="SerialLogScrollViewASCII"
Grid.ColumnSpan="6"
VerticalScrollBarVisibility="Always"
Grid.Row="0"
IsVisible="{Binding IsASCIILogVisible}"
BackgroundColor="Transparent">
<ListView x:Name="LogStackASCII"
ItemsSource="{Binding SerialLogASCII}"
BackgroundColor="Transparent"
ItemTapped="LogMessageTapped"
SelectionMode="Single">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>
<Grid PropertyChanged="SerialLogChanged" ColumnDefinitions="160,*" ColumnSpacing="5" BackgroundColor="Transparent">
<Label Text="{Binding Time}" Margin="0,0,10,0" Grid.Column="0" FontSize="12" BackgroundColor="Transparent"/>
<Label Text="{Binding Message}" LineBreakMode="CharacterWrap" Grid.Column="1" FontSize="12" BackgroundColor="Transparent"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollView>
<ScrollView x:Name="SerialLogScrollViewHEX"
Grid.ColumnSpan="6"
VerticalScrollBarVisibility="Always"
Grid.Row="0"
IsVisible="{Binding IsHEXLogVisible}"
BackgroundColor="Transparent">
<ListView x:Name="LogStackHEX"
ItemsSource="{Binding SerialLogHEX}"
BackgroundColor="Transparent"
ItemTapped="LogMessageTapped"
SelectionMode="Single">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>
<Grid PropertyChanged="SerialLogChanged" Padding="1" ColumnDefinitions="160,*" ColumnSpacing="5" BackgroundColor="Transparent">
<Label Text="{Binding Time}" Margin="0,0,10,0" Grid.Column="0" FontSize="12" BackgroundColor="Transparent"/>
<Label Text="{Binding Message}" LineBreakMode="CharacterWrap" Grid.Column="1" FontSize="12" BackgroundColor="Transparent"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollView>
</Grid>
Developer technologies | .NET | .NET MAUI
1 answer
Sort by: Most helpful
-
Thiemo 1 Reputation point
2022-12-29T10:43:58.337+00:00