Confusion about using OverrideMetadata when subclassing Noesis::Slider (example included)
Posted: 23 Nov 2025, 21:12
Hi,
I’m trying to create a custom slider by subclassing Noesis::Slider, but I’m running into confusion about how OverrideMetadata is supposed to be used in Noesis.
Goal for my test is to add a custom red background to the slider, but keep all other visual behavior and style from the default Noesis Slider.
Here is my current custom slider:
Note
Fslider works fine if instantiated in code.
Once I define Fslider in xaml and add reflection part, I see only background without track and thumb.
My question:
What should be the correct metadata override for DefaultStyleKeyProperty?
Is there any minimal working example showing how to extend a core Noesis control and override its metadata correctly?
Thanks.
Kind Regards,
Miroslav
I’m trying to create a custom slider by subclassing Noesis::Slider, but I’m running into confusion about how OverrideMetadata is supposed to be used in Noesis.
Goal for my test is to add a custom red background to the slider, but keep all other visual behavior and style from the default Noesis Slider.
Here is my current custom slider:
Code: Select all
class FSlider : public Noesis::Slider
{
public:
FSlider();
void OnValueChanged(float oldValue, float newValue) override;
void OnRender(Noesis::DrawingContext* drawingContext) override;
void SetColor(const Noesis::Color& newColor)
private:
Noesis::Color CurrentColor;
NS_IMPLEMENT_INLINE_REFLECTION(FSlider, Noesis::Slider)
{
auto* data = NsMeta<Noesis::DependencyData>(Noesis::TypeOf<SelfClass>());
// ---------- This is the part I’m confused about: -----------//
data->OverrideMetadata<Noesis::Slider>(
Noesis::Control::DefaultStyleKeyProperty,
"DefaultStyleKey",
Noesis::FrameworkPropertyMetadata::Create(Noesis::TypeOf<Noesis::Slider>())
);
}
};
Fslider works fine if instantiated in code.
Once I define Fslider in xaml and add reflection part, I see only background without track and thumb.
Code: Select all
<custom:FSlider x:Name="MyFSlider" Minimum="0" Maximum="5" Value="3" Width="100" Height="20"/>
What should be the correct metadata override for DefaultStyleKeyProperty?
Is there any minimal working example showing how to extend a core Noesis control and override its metadata correctly?
Thanks.
Kind Regards,
Miroslav