0

I'm trying to create a custom control that can be shared by both Silverlight and WPF. For the sake of this I don't use Triggers in my Custom control's templates which are not supported by Silverlight - instead I use Storyboard animations which seem to be supported by both platforms.

First, I made a Custom control which works well for Silverlight. Then tried to use it in WPF and kept getting the following runtime error: Property path is not valid. 'Shape' does not have a public property named 'Background'.

The following XAML in my Custom control template is the cause:

<VisualState x:Name="Hovered">
    <Storyboard>
       <ColorAnimation Duration="0:0:0"
                Storyboard.TargetName="PBorder"
                Storyboard.TargetProperty="(Shape.Background).(SolidColorBrush.Color)" To="White" />
    </Storyboard>
</VisualState>

What is the valid XAML syntax for this part of code for WPF specifically?
And is it possible to make this XAML valid for both Silverlight and WPF?

rem
  • 16,745
  • 37
  • 112
  • 180

1 Answers1

2

Shape does not have a Background but instead it has a Fill(Background) and a Stroke(Border).

decyclone
  • 30,394
  • 6
  • 63
  • 80
  • Unfortunately, it doesn't help. The above code doesn't work in wpf with `Shape.Fill` as it doesn't with `Shape.Background` – rem Mar 06 '11 at 17:56
  • OK. I've ended up with `(Background).(SolidColorBrush.Color)`, it works. – rem Mar 06 '11 at 19:26
  • What do you mean by `doesn't work`? Does it show any error in `Output Window`? – decyclone Mar 06 '11 at 19:27
  • It gives the error: `"'Fill' property does not point to a DependencyObject in path '(0).(1)'".` – rem Mar 07 '11 at 08:36