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

Failing to understand OverrideMetadata and how to use it

24 Aug 2020, 11:33

Hey,

I'm trying to change the global default timer for tooltips to stay open. In C# you could do:
ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue));
And this seems to work fine.

Now I'm trying to do this in C++, but I can't seem to get it to work. I think I don't understand how to use OverrideMetadata properly. I've tried:
//In main window Loaded Event, obviously Noesis::SystemInt32 is not the correct type here, but there is no TypeOf I could use with int32_t. 
Noesis::ToolTipService::ShowDurationProperty->OverrideMetadata(Noesis::TypeOf<Noesis::SystemInt32>(), PropertyMetadata::Create(int32_t(100)));

// In main view reflection. This actually gives conflicts when opening tooltips
data->OverrideMetadata<int32_t>(Noesis::ToolTipService::ShowDurationProperty, "ShowDuration", PropertyMetadata::Create(int32_t(100)));
But neither attempts give me a 0.1 second timeout (testing), but instead the 5 second default. Am I missing something?

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Failing to understand OverrideMetadata and how to use it

24 Aug 2020, 13:19

OverrideMetadata specifies a new metadata for the desired type (and derived classes). In that C# code you are saying that all DependencyObject (and derived) instances will have a default value for ShowDuration property of Int32.MaxValue milliseconds.

In theory the code should be the same for Noesis but I noticed that we are ignoring metadata overrides for DependencyObject type, could you please report it in our bugtracker? Anyway you could accomplish almost the same by overriding that property for UIElement type because you probably only want that behavior for UI elements in the visual tree.
ToolTipService::ShowDurationProperty->OverrideMetadata(TypeOf<UIElement>(), FrameworkPropertyMetadata::Create(int32_t(INT_MAX)));
 
Joren
Topic Author
Posts: 14
Joined: 12 Nov 2019, 15:33

Re: Failing to understand OverrideMetadata and how to use it

25 Aug 2020, 10:37

That explains it! Thanks.

I've reported the issue at #0001782

Who is online

Users browsing this forum: Google [Bot] and 0 guests