My control has 5 dependency properties. I set them in XAML like this:
<MyControl Prop1="1" Prop2="2" Prop3="3" Prop4="4" />
As you can see, I am only setting 4 of the 5 properties in XAML.
What I need to find is some mechanism to indicate that all the properties set in XAML have been processed. With this event, I can run my SetItAllUp() method.
Option 1. Use the DP setter
FAIL: Not an option because I cannot call SetItAllUp() but one time. This also has the side effect of activating based on the ordinal declaration of each DP in the XAML. If there is some type of chaining or dependency between my properties, this undermines it.
Option 2. Use the DP setter, and test all values are set
FAIL: Not an option because sometimes certain DP values are optional – let’s just pretend that the logic necessary to determine if optional values are properly set or not is too complex to implement this solution for now, please.
Option 3. Use MyControl.Loaded
FAIL: Not an option because this fires too early. In fact, every event I can see fires too early. It is almost as if the object is created and then something under the hood starts to set the DP values based on the declarations.
Update! Loaded is the solution. My question was flawed.
There’s some event or something, right?
// Thanks
Loaded works fine. Sorry for the confusion.
I tested this class:
With this XAML:
And got this Trace:
And it turns out Loaded works just fine.
My previous testing must have had some other factor.
My simplified test shows Loaded seems perfect.