Adorner with visual child
Posted: 21 Jul 2024, 19:35
Hi!
I'm trying to create an Adorner that renders a child element (e.g. a Border) instead of overriding OnRender method.
I have found WPF example here https://stackoverflow.com/questions/857 ... stackpanel which is also very similar to your EffectAdorner code, so I thought it will be simple enough, but I can't get it to work - the Border is not rendered.
Everything seems correct in the Inspector: the Border is a child of TestAdorner and has expected placement and size. It just isn't visible for some reason.
Am I doing something wrong here or is this usage unsupported?
I'm trying to create an Adorner that renders a child element (e.g. a Border) instead of overriding OnRender method.
I have found WPF example here https://stackoverflow.com/questions/857 ... stackpanel which is also very similar to your EffectAdorner code, so I thought it will be simple enough, but I can't get it to work - the Border is not rendered.
Everything seems correct in the Inspector: the Border is a child of TestAdorner and has expected placement and size. It just isn't visible for some reason.
Am I doing something wrong here or is this usage unsupported?
Code: Select all
TestAdorner::TestAdorner(UIElement* pAdornedElement) : Adorner(pAdornedElement)
{
Ptr<Border> pBorder = MakePtr<Border>();
pBorder->SetBackground(Brushes::Red());
m_pChild = pBorder;
AddVisualChild(m_pChild);
}
uint32_t TestAdorner::GetVisualChildrenCount() const
{
return 1;
}
Visual* TestAdorner::GetVisualChild(uint32_t index) const
{
return m_pChild;
}
Noesis::Size TestAdorner::MeasureOverride(const Noesis::Size&)
{
Noesis::UIElement* adornedElement = GetAdornedElement();
const Noesis::Size& adornedSize = adornedElement->GetRenderSize();
Noesis::Size finalSize = adornedSize;
m_pChild->Measure(finalSize);
return finalSize;
}
Noesis::Size TestAdorner::ArrangeOverride(const Noesis::Size&)
{
const Noesis::Size& finalSize = GetDesiredSize();
m_pChild->Arrange(Noesis::Rect(finalSize));
return finalSize;
}