Joren
Topic Author
Posts: 16
Joined: 12 Nov 2019, 15:33

Why can't I override metadata more then once?

14 Jan 2021, 10:46

Hi,

I want to expose this InitialShowDelayProperty setting to the user, I want to apply this value globally. Doing so for the first time seems to work perfectly.
Noesis::ToolTipService::InitialShowDelayProperty->OverrideMetadata(Noesis::TypeOf<Noesis::UIElement>(), Noesis::FrameworkPropertyMetadata::Create(value));
However if I want to override a second time, it will give me this error and seems to not do anything. Why is this? I expect to override the previous metadata. Is this a bug or do I not understand it properly?
 DependencyProperty 'InitialShowDelay' already has metadata for type 'UIElement'
 
User avatar
sfernandez
Site Admin
Posts: 2056
Joined: 22 Dec 2011, 19:20

Re: Why can't I override metadata more then once?

15 Jan 2021, 12:51

Hi,

OverrideMetadata is done by type, you can only override a dependency property metadata once for each type.
You need to think of this as something static (as in which is the default value for all UIElements, or for all Controls...), and are values you set once at start and can't change during application running.

Investigating ways of making those properties configurable at runtime for all ToolTips in an easy way I found the answer from archimed7592 in this StackOverflow post the most convincing:
https://stackoverflow.com/questions/952 ... y-globally

At application startup you would override the property for FrameworkElement type to make it inheritable:
Noesis::ToolTipService::InitialShowDelayProperty->OverrideMetadata(Noesis::TypeOf<Noesis::FrameworkElement>(),
    Noesis::FrameworkPropertyMetadata::Create(int32_t(400), Noesis::FrameworkPropertyMetadataOptions_Inherits));
Then just set the property value in the root element of your UI (or on the part where you want to apply this), preferably using a binding to the ViewModel.

Does that work for you?
 
Joren
Topic Author
Posts: 16
Joined: 12 Nov 2019, 15:33

Re: Why can't I override metadata more then once?

18 Jan 2021, 11:50

Thanks for the reply,

Yes this works indeed. Did come across that post myself but didn't really grasp what it was trying to do.

Thanks
 
User avatar
sfernandez
Site Admin
Posts: 2056
Joined: 22 Dec 2011, 19:20

Re: Why can't I override metadata more then once?

18 Jan 2021, 12:52

Great! thanks for the update.

Who is online

Users browsing this forum: No registered users and 0 guests