MarkupExtension for multiple styles in C++
Posted: 14 Dec 2021, 13:37
Hi,
I'm trying to implement a MultiStyle MarkupExtension that allows me to merge multiple Styles like
I'm, following
https://stackoverflow.com/questions/574 ... nd-basedon
The code works on the C# side but I'm having trouble using the StaticResourceExtension class to find the Style Resources in the ProvideValue function in C++.
I have this in C++ right now with a bunch of errors
What is the right way to get resources in C++ using a string? And is making 'key' a TypeClass from a string the right approach or should it be something else?
I'm trying to implement a MultiStyle MarkupExtension that allows me to merge multiple Styles like
Code: Select all
<Style x:key="Combined" BasedOn="{local:MultiStyle A B}">
... other properties.
</Style>https://stackoverflow.com/questions/574 ... nd-basedon
The code works on the C# side but I'm having trouble using the StaticResourceExtension class to find the Style Resources in the ProvideValue function in C++.
I have this in C++ right now with a bunch of errors
Code: Select all
Noesis::Ptr<BaseComponent> ProvideValue(const Noesis::ValueTargetProvider* provider) override {
Noesis::Ptr<Noesis::Style> resultStyle = *new Noesis::Style();
for (std::string currentResourceKey : resourceKeys)
{
Noesis::TypeClass key = Noesis::TypeClass(Noesis::Symbol(currentResourceKey.c_str()), false);
if (currentResourceKey == ".")
{
key = *(provider->GetTargetObject()->GetClassType());
}
Noesis::Ptr<Noesis::MarkupExtension> ext = Noesis::MakePtr<Noesis::MarkupExtension>();
Noesis::Style* currentStyle = Noesis::DynamicCast<Noesis::Style*>(ext->FindNodeResource(key.c_str(), true));
if (currentStyle == nullptr)
throw std::runtime_error("Invalid Style resource specified");
MultiStyleMethods::Merge(resultStyle, currentStyle);
}
return Noesis::Ptr<Noesis::Style>(resultStyle);
}