While working to help out Alan Beasley with his request for 'developer support' on his article
Picture Frame[
^], I ran across a few things in Silverlight 3 and 4 and Blend 4 RC that are worth mentioning.
Silverlight 3
SL 3 has a bug in how it parses out Xaml that leaves you with little to no information as to the true source (see
here[
^]).
This can be 'somewhat' overcome with the solution provided in the link above by using xmlns (with assembly) at the root element of the control template, ex:
<ControlTemplate TargetType="ContentControl">
<Grid x:Name="LayoutRoot" xmlns:y="clr-namespace:MyNamespace; assembly=MyAssembly">
<Path Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(y:MyClass.VerticalGradient)}" />
</Grid>
</ControlTemplate>
For those who do use the above, it still causes some issues with the Blend designer, as Alan informed me. But otherwise, it will still compile and run just fine.
I did though find another option that takes advantage of the XamlReader. I cannot personally vouche for this approach, as I did not try it, but it can be found
here[
^] posted by thejvk.
Silverlight 4
SL 4 does indeed resolve the bug mentioned above in allowing you to neglect applying the "xmlns" element to the root of the control template. So, the code snippet would now look like this:
<ControlTemplate TargetType="ContentControl">
<Grid x:Name="LayoutRoot"
<Path Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(y:MyClass.VerticalGradient)}" />
</Grid>
</ControlTemplate>
Blend 4 RC (4.0.20421.0)
While working with Blend 4 RC (4.0.20421.0), I found an interesting bug. When you open a solution that does not have the class which defines the dependency compiled, Blend will not show the dependency property until you compile and then reopen the solution.
Once reopened, Blend will interpret any changes made to the Dependency property and update the UI as soon as the changes are built.
Bonus Tip
When attempting to make your UI designer's life easier, you'll want to apply the attributes
BrowsableAttribute[
^],
CategoryAttribute[
^], and
DescriptionAttribute[
^] to the GetXXX method of your dependency property. This method is the method of choice that Visual Studio and Blend look at when pulling information about your dependency property (see the remarks of
this[
^]).