diff --git a/src/DodoSSH.Client.Android/Views/PendingScreen.axaml b/src/DodoSSH.Client.Android/Views/PendingScreen.axaml index 8c6904e..c4b79c8 100644 --- a/src/DodoSSH.Client.Android/Views/PendingScreen.axaml +++ b/src/DodoSSH.Client.Android/Views/PendingScreen.axaml @@ -2,7 +2,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="using:DodoSSH.Client.Android.Views" x:Class="DodoSSH.Client.Android.Views.PendingScreen" - x:DataType="views:PendingScreen" Background="{StaticResource Canvas}"> @@ -24,11 +27,11 @@ HorizontalAlignment="Center" VerticalAlignment="Center" /> - - diff --git a/src/DodoSSH.Client.Android/Views/PendingScreen.axaml.cs b/src/DodoSSH.Client.Android/Views/PendingScreen.axaml.cs index 7fe36ce..afb7644 100644 --- a/src/DodoSSH.Client.Android/Views/PendingScreen.axaml.cs +++ b/src/DodoSSH.Client.Android/Views/PendingScreen.axaml.cs @@ -8,8 +8,25 @@ namespace DodoSSH.Client.Android.Views; /// A state this head has not built, saying so in its own words. /// /// +/// /// Styled properties rather than a view model: there is no state behind this control, and giving it one /// would make it look like a screen that might one day have data. +/// +/// +/// It must not set its own DataContext, and the two properties are read with $parent for exactly +/// that reason. This control once did DataContext = this so the properties could be bound as +/// {Binding Heading}, and it cost the phone its navigation. A binding written by the parent +/// on one of these — IsVisible="{Binding IsPreferencesShowing}" in PhoneShell — resolves against +/// this control's own data context, so with one set here the binding looked for a shell property on a +/// PendingScreen, found nothing, and left IsVisible at its default of true. The result was an opaque +/// PREFERENCES panel permanently on top of the host list, over a bottom bar whose buttons all worked +/// perfectly and changed nothing anybody could see. +/// +/// +/// The desktop head carries the other half of this lesson in MainWindow.axaml, where the terminal's +/// visibility is given a FallbackValue for the same reason: an unresolved IsVisible binding +/// does not hide anything, it shows everything. +/// /// internal sealed partial class PendingScreen : UserControl { @@ -19,15 +36,7 @@ internal sealed partial class PendingScreen : UserControl public static readonly StyledProperty DetailProperty = AvaloniaProperty.Register(nameof(Detail), string.Empty); - public PendingScreen() - { - AvaloniaXamlLoader.Load(this); - - // Its own data context, so the two properties can be bound in XAML like anything else. Safe here - // and only here: this control deliberately shows nothing from the shell, so there is no inherited - // context worth keeping. - DataContext = this; - } + public PendingScreen() => AvaloniaXamlLoader.Load(this); public string Heading {