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>
|
</Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<mux:ItemsRepeaterScrollHost>
|
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<StackPanel>
|
<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}"
|
ItemsSource="{x:Bind Equations}"
|
||||||
|
SelectionMode="None"
|
||||||
TabFocusNavigation="Local">
|
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">
|
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||||
<controls:EquationTextBox x:Uid="EquationInputButton"
|
<controls:EquationTextBox x:Uid="EquationInputButton"
|
||||||
Margin="1,0,1,2"
|
Margin="1,0,1,2"
|
||||||
@ -808,25 +830,33 @@
|
|||||||
</controls:EquationTextBox.ColorChooserFlyout>
|
</controls:EquationTextBox.ColorChooserFlyout>
|
||||||
</controls:EquationTextBox>
|
</controls:EquationTextBox>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</mux:ItemsRepeater.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</mux:ItemsRepeater>
|
</ListView>
|
||||||
<StackPanel x:Name="VariableStackPanel" x:Load="{x:Bind local:EquationInputArea.ManageEditVariablesButtonLoaded(Variables.Size), Mode=OneWay}">
|
<StackPanel x:Name="VariableStackPanel" x:Load="{x:Bind local:EquationInputArea.ManageEditVariablesButtonLoaded(Variables.Size), Mode=OneWay}">
|
||||||
<Rectangle Height="1"
|
<Rectangle Height="1"
|
||||||
Margin="12"
|
Margin="12"
|
||||||
Fill="#33000000"/>
|
Fill="#33000000"/>
|
||||||
<mux:ItemsRepeater ItemTemplate="{StaticResource VariableDataTemplate}"
|
<ListView IsItemClickEnabled="False"
|
||||||
|
ItemTemplate="{StaticResource VariableDataTemplate}"
|
||||||
ItemsSource="{x:Bind Variables, Mode=OneWay}"
|
ItemsSource="{x:Bind Variables, Mode=OneWay}"
|
||||||
|
SelectionMode="None"
|
||||||
TabFocusNavigation="Local">
|
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>
|
<TransitionCollection>
|
||||||
<AddDeleteThemeTransition/>
|
<AddDeleteThemeTransition/>
|
||||||
</TransitionCollection>
|
</TransitionCollection>
|
||||||
</mux:ItemsRepeater.Transitions>
|
</ListView.Transitions>
|
||||||
</mux:ItemsRepeater>
|
</ListView>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</mux:ItemsRepeaterScrollHost>
|
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -149,7 +149,7 @@ void EquationInputArea::FocusEquationTextBox(EquationViewModel ^ equation)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto container = EquationInputList->TryGetElement(index);
|
auto container = EquationInputList->ContainerFromIndex(index);
|
||||||
if (container == nullptr)
|
if (container == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -234,7 +234,7 @@ void EquationInputArea::EquationTextBox_Loaded(Object ^ sender, RoutedEventArgs
|
|||||||
unsigned int index;
|
unsigned int index;
|
||||||
if (Equations->IndexOf(copyEquationToFocus, &index))
|
if (Equations->IndexOf(copyEquationToFocus, &index))
|
||||||
{
|
{
|
||||||
auto container = EquationInputList->TryGetElement(index);
|
auto container = static_cast<UIElement^>(EquationInputList->ContainerFromIndex(index));
|
||||||
if (container != nullptr)
|
if (container != nullptr)
|
||||||
{
|
{
|
||||||
container->StartBringIntoView();
|
container->StartBringIntoView();
|
||||||
@ -264,7 +264,7 @@ void EquationInputArea::FocusEquationIfNecessary(CalculatorApp::Controls::Equati
|
|||||||
unsigned int index;
|
unsigned int index;
|
||||||
if (Equations->IndexOf(m_equationToFocus, &index))
|
if (Equations->IndexOf(m_equationToFocus, &index))
|
||||||
{
|
{
|
||||||
auto container = EquationInputList->TryGetElement(index);
|
auto container = static_cast<UIElement ^>(EquationInputList->ContainerFromIndex(index));
|
||||||
if (container != nullptr)
|
if (container != nullptr)
|
||||||
{
|
{
|
||||||
container->StartBringIntoView();
|
container->StartBringIntoView();
|
||||||
|
Loading…
Reference in New Issue
Block a user