- XaeroDegreaz
- Posts: 29
- Joined:
Unity - Framerate drops when pressing shift+tab, tab or clicking rightmost column inside of a ListView
A picture is worth a thousand words:
Here's the code-behind:
Here's the WPF:
I'd also like to not that it only seems to happen when there are actually items in the list.
Another note:
I tried changing the width of the two columns so that the right-most column is not wide enough to reach the edge of the grid and that stopped it from freaking out. I think it's related to the problem: viewtopic.php?f=3&t=1045
Here's the code-behind:
Code: Select all
using System.Collections.ObjectModel;
using Noesis;
namespace KazBall.Ui.Hud
{
public class ScoreScreen : UserControl
{
public ScoreScreen()
{
Initialized += ( sender, args ) => { DataContext = new ScoreScreenViewModel( this ); };
GUI.LoadComponent( this, "Assets/Ui/Hud/ScoreScreen.xaml" );
}
}
public class ScoreScreenViewModel
{
public class ScoreItem
{
public string PlayerName { get; set; }
public int Score { get; set; }
public string TeamColour { get; set; }
}
public ObservableCollection<ScoreItem> ScoreItems { get; set; } = new ObservableCollection<ScoreItem>();
public ScoreScreenViewModel( UserControl rootControl )
{
ScoreItems.Add( new ScoreItem {PlayerName = "Player 1", Score = 1, TeamColour = "Red"} );
ScoreItems.Add( new ScoreItem {PlayerName = "Player 1", Score = 1, TeamColour = "LightBlue"} );
//# These fix the "Tab" key, but not the "Shift + Tab"
//rootControl.KeyDown += ( sender, args ) => args.Handled = true;
//rootControl.PreviewKeyDown += ( sender, args ) => args.Handled = true;
}
}
}
Code: Select all
<UserControl
KeyboardNavigation.TabNavigation="None"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="KazBall.Ui.Hud.ScoreScreen"
d:DesignWidth="640" d:DesignHeight="480">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListView
x:Name="ListView"
Grid.ColumnSpan="2"
ItemsSource="{Binding ScoreItems}">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn
Header="Player"
Width="{Binding ActualWidth, ElementName=LeftColumn}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding PlayerName}"
Foreground="{Binding TeamColour}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn
Header="Score"
Width="{Binding ActualWidth, ElementName=RightColumn}"
DisplayMemberBinding="{Binding Score}"/>
</GridView>
</ListView.View>
</ListView>
<!-- Stupid hack for grid view columns to auto width -->
<Grid Visibility="Hidden">
<Grid Grid.Column="1" x:Name="LeftColumn" />
<Grid Grid.Column="2" x:Name="RightColumn" />
</Grid>
</Grid>
</UserControl>
Another note:
I tried changing the width of the two columns so that the right-most column is not wide enough to reach the edge of the grid and that stopped it from freaking out. I think it's related to the problem: viewtopic.php?f=3&t=1045
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Unity - Framerate drops when pressing shift+tab, tab or clicking rightmost column inside of a ListView
Something very bad and unexpected is happening there
We will investigate this issue and fix it as soon as possible.
We will investigate this issue and fix it as soon as possible.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 13 guests