Question

anyone know how can i use VSM chang a textblock text color from "Red" to "Blue" ?do textblock have temeplate like Button,TextBox... and so on ? thanks for you help and looking forward to your reply...

Was it helpful?

Solution

you can use Textbox and set color background on mouse over

<TextBox TextWrapping="Wrap" Background="#FFBA2C2C" Height="20">
        <TextBox.Template>
            <ControlTemplate>
                <StackPanel Orientation="Horizontal">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal"/>
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <ColorAnimation  To="Red" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock" d:IsOptimized="True" Duration="0"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <TextBlock x:Name="textBlock" Text="Click Me"/>
                    </StackPanel>
            </ControlTemplate>
        </TextBox.Template>
    </TextBox>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top