Work around crash by replacing ItemRepeater with ListView (#1058)
* Replace ItemRepeater with ListView * Allow animations * undo temp key change * Remove animation
This commit is contained in:
parent
2caea01c6f
commit
ebc57af203
@ -775,13 +775,35 @@
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<mux:ItemsRepeaterScrollHost>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<mux:ItemsRepeater x:Name="EquationInputList"
|
||||
<!-- This ListView and the one below should be replacted by an ItemRepeater once https://github.com/microsoft/microsoft-ui-xaml/issues/2011 is fixed. -->
|
||||
<ListView x:Name="EquationInputList"
|
||||
IsItemClickEnabled="False"
|
||||
ItemsSource="{x:Bind Equations}"
|
||||
SelectionMode="None"
|
||||
TabFocusNavigation="Local">
|
||||
<mux:ItemsRepeater.ItemTemplate>
|
||||
|
||||
<!-- Removes animations from the ListView Style. -->
|
||||
<ListView.Style>
|
||||
<Style TargetType="ListView">
|
||||
<Setter Property="ItemContainerTransitions">
|
||||
<Setter.Value>
|
||||
<TransitionCollection/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListView.Style>
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="1,0,1,0"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||
<controls:EquationTextBox x:Uid="EquationInputButton"
|
||||
Margin="1,0,1,2"
|
||||
@ -808,25 +830,33 @@
|
||||
</controls:EquationTextBox.ColorChooserFlyout>
|
||||
</controls:EquationTextBox>
|
||||
</DataTemplate>
|
||||
</mux:ItemsRepeater.ItemTemplate>
|
||||
</mux:ItemsRepeater>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<StackPanel x:Name="VariableStackPanel" x:Load="{x:Bind local:EquationInputArea.ManageEditVariablesButtonLoaded(Variables.Size), Mode=OneWay}">
|
||||
<Rectangle Height="1"
|
||||
Margin="12"
|
||||
Fill="#33000000"/>
|
||||
<mux:ItemsRepeater ItemTemplate="{StaticResource VariableDataTemplate}"
|
||||
<ListView IsItemClickEnabled="False"
|
||||
ItemTemplate="{StaticResource VariableDataTemplate}"
|
||||
ItemsSource="{x:Bind Variables, Mode=OneWay}"
|
||||
SelectionMode="None"
|
||||
TabFocusNavigation="Local">
|
||||
<mux:ItemsRepeater.Transitions>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="1,0,1,0"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.Transitions>
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</mux:ItemsRepeater.Transitions>
|
||||
</mux:ItemsRepeater>
|
||||
</ListView.Transitions>
|
||||
</ListView>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</ScrollViewer>
|
||||
</mux:ItemsRepeaterScrollHost>
|
||||
|
||||
</UserControl>
|
||||
|
@ -149,7 +149,7 @@ void EquationInputArea::FocusEquationTextBox(EquationViewModel ^ equation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto container = EquationInputList->TryGetElement(index);
|
||||
auto container = EquationInputList->ContainerFromIndex(index);
|
||||
if (container == nullptr)
|
||||
{
|
||||
return;
|
||||
@ -234,7 +234,7 @@ void EquationInputArea::EquationTextBox_Loaded(Object ^ sender, RoutedEventArgs
|
||||
unsigned int index;
|
||||
if (Equations->IndexOf(copyEquationToFocus, &index))
|
||||
{
|
||||
auto container = EquationInputList->TryGetElement(index);
|
||||
auto container = static_cast<UIElement^>(EquationInputList->ContainerFromIndex(index));
|
||||
if (container != nullptr)
|
||||
{
|
||||
container->StartBringIntoView();
|
||||
@ -264,7 +264,7 @@ void EquationInputArea::FocusEquationIfNecessary(CalculatorApp::Controls::Equati
|
||||
unsigned int index;
|
||||
if (Equations->IndexOf(m_equationToFocus, &index))
|
||||
{
|
||||
auto container = EquationInputList->TryGetElement(index);
|
||||
auto container = static_cast<UIElement ^>(EquationInputList->ContainerFromIndex(index));
|
||||
if (container != nullptr)
|
||||
{
|
||||
container->StartBringIntoView();
|
||||
|
Loading…
Reference in New Issue
Block a user