Skip to content

Commit

Permalink
Fix for "System.ArgumentException: Unable to find IAnimationManager f…
Browse files Browse the repository at this point in the history
…or ... (this control)"
  • Loading branch information
Keflon committed Feb 2, 2024
1 parent 68edd35 commit 703cded
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
22 changes: 22 additions & 0 deletions FunctionZero.Maui.Controls/Controls/Expander/ExpanderZero.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ namespace FunctionZero.Maui.Controls;
public partial class ExpanderZero : ContentView
{
private ContentPresenter _detailView;
private bool _loaded;

public ExpanderZero()
{
InitializeComponent();
this.Loaded += ExpanderZero_Loaded;
}



private void ExpanderZero_Loaded(object sender, EventArgs e)
{
// This dodges something related to this: https://github.com/dotnet/maui/pull/6364
// where
// IsExpanded="{z:Bind '!Device.IsDeviceConnected'}"
// can cause
// System.ArgumentException: Unable to find IAnimationManager for ... (this control)
// I guess because z:Bind flips the value when the binding context is set but before the control
// is in the visual tree, meaning there is no IAnimationManager available.
// Note, my logic may be incorrect, but the problem we're dodging is specific to the '!' in the zBind expression.

_loaded = true;
UpdateVisualState(IsExpanded);
}

public static readonly BindableProperty OrientationProperty = BindableProperty.Create(nameof(Orientation), typeof(StackOrientation), typeof(ExpanderZero), StackOrientation.Vertical, BindingMode.OneWay, null, OrientationChanged);
Expand Down Expand Up @@ -130,6 +150,8 @@ protected override async void OnApplyTemplate()
}
private void UpdateVisualState(bool isExpanded)
{
if(_loaded == false)
return;

ContentPresenter container = _detailView;
_detailView.IsClippedToBounds = true;
Expand Down
4 changes: 2 additions & 2 deletions FunctionZero.Maui.Controls/FunctionZero.Maui.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<PackageProjectUrl>https://github.com/Keflon/FunctionZero.Maui.Controls</PackageProjectUrl>
<RepositoryUrl>https://github.com/Keflon/FunctionZero.Maui.Controls</RepositoryUrl>
<PackageTags>MAUI; ListView; ListViewZero; TreeView; TreeViewZero; MaskView; iOS; WinUI; Windows; Android; Control </PackageTags>
<PackageReleaseNotes>Working out some kinks with the MarkupExtension for swapping language translations at runtime.</PackageReleaseNotes>
<PackageReleaseNotes>Dodging MAUI bug: 'Unable to find IAnimationManager ...' if IsExpanded flips before the Expander is presented.</PackageReleaseNotes>
<PackageLicenseFile>License.md</PackageLicenseFile>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>8.0.0.2-pre4</Version>
<Version>8.0.0.2-pre5</Version>
<PackageIcon>F0 gravatar.png</PackageIcon>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="FunctionZero.Maui.MvvmZero" Version="2.0.3" />
<PackageReference Include="FunctionZero.Maui.MvvmZero" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 703cded

Please sign in to comment.