[Perf] Set x:Load=false for StandardOperators

As a workaround for nventive/Uno#925 (binding to x:Load doesn't work), this improves start-up time when going directly to calculators other than Standard.
This commit is contained in:
David Oliver 2019-05-27 14:05:21 -04:00
commit 99c1af1ecd
3 changed files with 19 additions and 1 deletions

View file

@ -301,6 +301,11 @@ namespace CalculatorApp
void OnIsStandardPropertyChanged(bool oldValue, bool newValue) void OnIsStandardPropertyChanged(bool oldValue, bool newValue)
{ {
if (newValue)
{
EnsureStandard();
}
UpdateViewState(); UpdateViewState();
UpdatePanelViewState(); UpdatePanelViewState();
} }
@ -430,6 +435,11 @@ namespace CalculatorApp
} }
} }
void EnsureStandard()
{
OpsPanel.EnsureStandardOps();
}
void EnsureScientific() void EnsureScientific()
{ {
OpsPanel.EnsureScientificOps(); OpsPanel.EnsureScientificOps();

View file

@ -11,7 +11,7 @@
<Grid> <Grid>
<!--Bind visibility as a workaround for nventive/Uno#925--> <!--Bind visibility as a workaround for nventive/Uno#925-->
<local:CalculatorStandardOperators x:Name="StandardOperators" <local:CalculatorStandardOperators x:Name="StandardOperators"
x:Load="{x:Bind Model.IsStandard, Mode=OneWay}" x:Load="False"
IsEnabled="{x:Bind Model.IsStandard, Mode=OneWay}" IsEnabled="{x:Bind Model.IsStandard, Mode=OneWay}"
Visibility="{x:Bind Model.IsStandard, Mode=OneWay}" Visibility="{x:Bind Model.IsStandard, Mode=OneWay}"
TabIndex="17" /> TabIndex="17" />

View file

@ -88,6 +88,14 @@ namespace CalculatorApp
} }
} }
internal void EnsureStandardOps()
{
if (StandardOperators == null)
{
this.FindName("StandardOperators");
}
}
internal void EnsureScientificOps() internal void EnsureScientificOps()
{ {
if (ScientificOperators == null) if (ScientificOperators == null)