LykosAI/StabilityMatrix · error · NullReferenceException
Frame not found
Error message
Frame not found
What it means
FrameCarousel.OnApplyTemplate looks up the template part 'PART_Frame' (a Frame) in the applied template's name scope. If the part is absent, it throws NullReferenceException('Frame not found'), preventing navigation wiring (NavigationPageFactory and initial navigation) from completing.
Solutions
- Include <Frame x:Name="PART_Frame"/> in the FrameCarousel ControlTemplate
- Verify the applied style/theme is the one intended for FrameCarousel
- Preserve the 'PART_Frame' TemplatePart name in any custom template
- Log/inspect e.NameScope in OnApplyTemplate to confirm which parts were found
Example fix
// before <ControlTemplate> <Panel/> </ControlTemplate> // after <ControlTemplate> <Frame x:Name="PART_Frame"/> </ControlTemplate>
Defensive patterns
Strategy: validation
Validate before calling
var frame = e.NameScope.Find<Frame>("PART_Frame");
if (frame is null) { Log.Error("PART_Frame missing from FrameCarousel template"); return; } Type guard
bool HasFramePart(TemplatedControl c) => c.Template != null;
Try / catch
try { frame = e.NameScope.Find<Frame>("PART_Frame")!; }
catch (NullReferenceException ex) { Log.Error(ex, "Frame part not found"); } Prevention
- Always preserve PART_* naming when re-templating
- Declare [TemplatePart(nameof(PART_Frame), typeof(Frame))] on the control
- Add design-time/template unit tests that apply the template
When it happens
Trigger: The FrameCarousel ControlTemplate lacks an element named 'PART_Frame', the template was overridden with a style that omits the part, or the Frame is not in the templated control's name scope.
Common situations: Custom re-templating of FrameCarousel that forgot the PART_Frame convention; theme assembly mismatch; renaming the part in a refactor.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- DockControl not found
- Font NotoSansJP not found
- Uri has unsupported scheme. Uri
- Cannot convert NaN to a numeric type
- Specified argument was out of range of valid values…
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/dc5cc8ca0c819f3d.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/Controls/FrameCarousel.axaml.cs:72
{
Effect = SlideNavigationTransitionEffect.FromLeft,
FromHorizontalOffset = 200
}
};
private static readonly FrameNavigationOptions DirectionlessNavigationOptions
= new()
{
TransitionInfoOverride = new SuppressNavigationTransitionInfo()
};
/// <inheritdoc />
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
frame = e.NameScope.Find<Frame>("PART_Frame")
?? throw new NullReferenceException("Frame not found");
frame.NavigationPageFactory = new FrameNavigationFactory(SourcePageType);
if (SelectedItem is not null)
{
frame.NavigateFromObject(SelectedItem, DirectionlessNavigationOptions);
}
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (frame is null) return;
if (change.Property == SelectedItemProperty)
{
if (change.GetNewValue<object?>() is not { } value) return;View on GitHub (pinned to af93d6ef57)