stride3d/stride · error · InvalidOperationException
The associated slider must have a Track child named…
Error message
The associated slider must have a Track child named 'PART_Track'
What it means
SliderDragFromTrackBehavior lets users start dragging the slider thumb by clicking anywhere on the slider's track. In SliderInitialized it applies the template and looks for a Track visual child; if none is found or the found track is not named 'PART_Track', it throws InvalidOperationException because dragging cannot be wired up without the standard slider Track part.
Solutions
- Restore a <Track x:Name="PART_Track"/> element in the slider's ControlTemplate (standard Slider templates always include it).
- Ensure the Track's name is exactly PART_Track — the check is case-sensitive and name-based.
- Verify the behavior is attached to a Slider that actually loads that template (correct Template/Style applied, not a fallback).
- If the template can't change, remove the behavior or implement track-click handling without this behavior.
Example fix
<!-- before: custom template without a Track part -->
<ControlTemplate TargetType="Slider">
<Border Background="{TemplateBinding Background}" />
</ControlTemplate>
<!-- after -->
<ControlTemplate TargetType="Slider">
<Track x:Name="PART_Track" Value="{TemplateBinding Value}">
<Track.Thumb>
<Thumb />
</Track.Thumb>
</Track>
</ControlTemplate> Defensive patterns
Strategy: validation
Validate before calling
slider.ApplyTemplate();
var track = slider.FindVisualChildOfType<Track>();
if (track == null || track.Name != "PART_Track")
log.Warn("Slider template lacks PART_Track; SliderDragFromTrackBehavior will throw."); Type guard
static bool HasSliderTrackPart(Slider s) { s.ApplyTemplate(); var t = s.FindVisualChildOfType<Track>(); return t?.Name == "PART_Track"; } Try / catch
try { behavior.Attach(slider); }
catch (InvalidOperationException ex) when (ex.Message.Contains("PART_Track")) { log.Error("Slider template must include <Track x:Name='PART_Track'/>"); } Prevention
- Base custom slider styles on the default Slider template so PART_Track is preserved.
- Never rename or remove the PART_Track part in a custom template.
- Smoke-test custom-styled sliders with this behavior attached before shipping themes.
When it happens
Trigger: Attaching the behavior to a custom slider whose ControlTemplate does not include a Track named PART_Track, or whose template hasn't produced a Track visual child after ApplyTemplate; attaching before/during template application such that FindVisualChildOfType<Track> runs too early in some custom templates.
Common situations: Using a custom or third-party slider style that renamed or removed PART_Track; building a minimal slider template for a lightweight look without a Track; attaching the behavior to a control that isn't actually a slider template host.
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
- This behavior must be attached to an instance of…
- The OnComboBoxClosedWithSelectionBehavior must be attached…
- The OnSelectionChangedWithSelectionBehavior must be…
- The EventName property must be set on behavior
- TODO: several events found, find a way to decide the most…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/52b74bae45339ecd.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/Behaviors/SliderDragFromTrackBehavior.cs:46
protected override void OnDetaching()
{
AssociatedObject.Initialized -= SliderInitialized;
AssociatedObject.RemoveHandler(UIElement.PreviewMouseLeftButtonDownEvent, (MouseButtonEventHandler)TrackMouseEvent);
AssociatedObject.RemoveHandler(UIElement.PreviewMouseLeftButtonUpEvent, (MouseButtonEventHandler)TrackMouseEvent);
if (track != null && track.Thumb != null)
{
track.Thumb.MouseEnter -= MouseEnter;
}
base.OnDetaching();
}
private void SliderInitialized(object sender, EventArgs e)
{
AssociatedObject.ApplyTemplate();
track = AssociatedObject.FindVisualChildOfType<Track>();
if (track == null || track.Name != "PART_Track")
throw new InvalidOperationException("The associated slider must have a Track child named 'PART_Track'");
track.Thumb.MouseEnter += MouseEnter;
AssociatedObject.Initialized += SliderInitialized;
}
private void TrackMouseEvent(object sender, [NotNull] MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
trackMouseDown = e.ButtonState == MouseButtonState.Pressed;
}
private void MouseEnter(object sender, [NotNull] MouseEventArgs e)
{
if (trackMouseDown)
{
var args = new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, MouseButton.Left) { RoutedEvent = UIElement.MouseLeftButtonDownEvent };
track.Thumb.RaiseEvent(args);
trackMouseDown = false;
}View on GitHub (pinned to 96fad776d2)