InvalidOperationException in VS2010

I am using Expression Blend 4 + Visual Studio 2010 Pro to create a WPF application.

I created a control (or should I specify a template?) Based on CheckBox using only Blend 4, which works fine. However, when I switch to VS2010, I get the following "error":

Property

'[Unknown]' does not point to a DependencyObject in the path '(0). (10]. (2) '.

Despite the fact that when you run the application, it works fine. Now I do not need to correct this error, but I would still like to get rid of it.

Here is the XAML style code:

<Style x:Key="IRSensorCheckBoxStyle" TargetType="{x:Type CheckBox}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type CheckBox}">
          <Grid Cursor="Hand">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal">
                  <Storyboard>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeThickness)" Storyboard.TargetName="ellipse">
                      <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="MouseOver">
                  <Storyboard>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeThickness)" Storyboard.TargetName="ellipse">
                      <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="2"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Pressed">
                  <Storyboard>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.StrokeThickness)" Storyboard.TargetName="ellipse">
                      <EasingDoubleKeyFrame KeyTime="0" Value="2"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Disabled"/>
              </VisualStateGroup>
              <VisualStateGroup x:Name="CheckStates">
                <VisualState x:Name="Checked">
                  <Storyboard>
                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ellipse">
                      <EasingColorKeyFrame KeyTime="0:0:0.3" Value="Red"/>
                    </ColorAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Unchecked">
                  <Storyboard>
                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ellipse">
                      <EasingColorKeyFrame KeyTime="0:0:0.2" Value="#00FF0000"/>
                    </ColorAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Indeterminate"/>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Ellipse x:Name="ellipse" Stroke="Yellow" StrokeThickness="0">
              <Ellipse.Fill>
                <RadialGradientBrush>
                  <GradientStop Color="Red"/>
                  <GradientStop Offset="1" Color="#00FF0000"/>
                </RadialGradientBrush>
              </Ellipse.Fill>
            </Ellipse>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

Storyboards Checked and Unchecked. ​​, DependencyObject ( , ...), Target "", ; Target , (Ellipse Fill); GradientStops [0] GreadientBrush, RadialGradientBrush; , , GradientStop Color, .

- ?

.

+3
1

- ( , ):

GradientStop, Color:

<Ellipse.Fill>
  <RadialGradientBrush>
    <GradientStop x:Name="Offset0" Color="Red"/>
    <GradientStop x:Name="Offset1" Offset="1" Color="#00FF0000"/>
  </RadialGradientBrush>
</Ellipse.Fill>

[...]

<VisualState x:Name="Checked">
  <Storyboard>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="Color" Storyboard.TargetName="Offset0">
      <EasingColorKeyFrame KeyTime="0:0:0.3" Value="Red"/>
    </ColorAnimationUsingKeyFrames>
  </Storyboard>
</VisualState>
<VisualState x:Name="Unchecked">
  <Storyboard>
    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="Color" Storyboard.TargetName="Offset0">
      <EasingColorKeyFrame KeyTime="0:0:0.2" Value="#00FF0000"/>
    </ColorAnimationUsingKeyFrames>
  </Storyboard>
</VisualState>

, , , , .

+2

Source: https://habr.com/ru/post/1778382/


All Articles