This is a migrated thread and some comments may be shown as answers.

How to change RadDiagramShape background color with VisualStateManager in xaml

1 Answer 165 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Nurzed
Top achievements
Rank 1
Nurzed asked on 18 Feb 2013, 07:32 AM
Hi Telerik team'

I want to change Background/Border color of RadDiagramShape when it selected. And I have tried VisualStateManager in the xaml coding but not works VisualState Events (MouseOver, Selected ...).

How to solve it? Please help me.

<DataTemplate x:Key="ClassTemplate">
    <Grid x:Name="Root">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="MouseOver">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="#FFF0FFE4" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                        <ColorAnimation Duration="0" To="#FFA5CA91" Storyboard.TargetProperty="(BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Pressed">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="#FFF0FFE4" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                        <ColorAnimation Duration="0" To="#FFA5CA91" Storyboard.TargetProperty="(BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Disabled" />
            </VisualStateGroup>
            <VisualStateGroup x:Name="FocusStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0" />
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Unfocused">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="#FFF0FFE4" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                        <ColorAnimation Duration="0" To="#FFA5CA91" Storyboard.TargetProperty="(BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Focused">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="#FFF0FFE4" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                        <ColorAnimation Duration="0" To="#FFA5CA91" Storyboard.TargetProperty="(BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="SelectionStates">
                <VisualState x:Name="Unselected" />
                <VisualState x:Name="Selected">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="#FFF0FFE4" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                        <ColorAnimation Duration="0" To="#FFA5CA91" Storyboard.TargetProperty="(BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="SelectedUnfocused">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="#FFF0FFE4" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                        <ColorAnimation Duration="0" To="#FFA5CA91" Storyboard.TargetProperty="(BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="ShapeBorder"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Border BorderBrush="#FF87ACBE" BorderThickness="2" VerticalAlignment="Top" Grid.RowSpan="2"
            CornerRadius="5" Background="#FFF1FAFF" x:Name="ShapeBorder">

<!-- ... -->

        </Border>
    </Grid>
</DataTemplate>

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 20 Feb 2013, 01:30 PM
Hello Nurzed,

I have answered a similar question in this forum thread. Please take a look at the attached project in that post and let me know if it works for you.

Regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
Nurzed
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or