Skip to content

Is it possible to add a static event to an attached property and lazy-initialize it? #4360

Answered by DarranRowe
sxlllslgh asked this question in Q&A
Discussion options

You must be logged in to vote

Event is a structure, but it isn't a smart pointer class like winrt::Microsoft::UI::Xaml::DependencyProperty or winrt::Microsoft::UI::Xaml::DependencyObject. So the only way to have lazy initialisation on event is to use std::optional or a pointer (std::unique_pointer would be preferred for lifetime reasons.)
It isn't, however, much of a problem to just initialise it as is, since it doesn't contain anything too big on construction.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sxlllslgh
Comment options

Answer selected by sxlllslgh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants