Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Property Element Syntax with Custom Controls?
3 replies. Latest Post by jasonxz on October 11, 2007.
(0)
wkamir
Member
2 points
4 Posts
10-11-2007 9:36 AM |
Hi Silverlight Enthusiasts :)
I tried to spice up my custom control a little and exposed another property named 'Background' which routes through to the canvas's background...
public
Trying to set the property in xaml:
<slControls:
<
</
throws an error. Of course if i omit the slControls prefix at the Background Property Element, it still does'nt work... anyone here who knows how to do this? Or is this just plain impossible with custom silverlight controls?
Best regards,Wolfgang
jasonxz
Participant
1750 points
529 Posts
10-11-2007 10:12 AM |
The problem, here, is that the syntax you're using in XAML to define the Background only works for dependency properties. If you, instead, used "Background='"Black'", it should work. Unfortunately, there's no way to create a Gradient background with that method and there's no way, yet, to create your own dependency property.
The only way I know of around all of this is to have your custom control inherit from Canvas instead of Control. Then, you could use Canvas.Background.
10-11-2007 10:33 AM |
Oh bummer :( that renders custom controls kind of useless... or at least really limits their usefulness.
Thanks for the hint though!
10-11-2007 11:42 AM |
Well, hopefully, we'll get the ability to create our own dependency properties by the time SL goes live and that will fix this problem.