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

Validation Error Tool Tip Template

1 Answer 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
band
Top achievements
Rank 1
band asked on 16 Mar 2017, 03:02 PM

At the moment, validation only appears when you hover over the cell that didn't pass validation. Is there a way to show the validation without the mouse hovering? 

 

http://i.imgur.com/zvWqKn6.png

 

 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 21 Mar 2017, 09:55 AM
Hello band,

Quoting the answer from this thread:

"Basically, you cannot force the tooltip to be shown constantly, because Windows is the one who decides when the tooltip hides (usually on MouseLeave or after some amount of time) to keep the look and feel of the applications consistent (The tooltip control is made to act this way).

If you want to display some helpful information to the user in a way that differs from the standard Windows tooltip way, you should consider using something else than a ToolTip, maybe a Popup."

With this said, you can predefine the control template of the GridViewEditorPresenter element and replace the tooltip with a Popup, for example:

<ControlTemplate x:Key="GridViewEditorPresenterTemplate" TargetType="grid:GridViewEditorPresenter">
    <Grid>
        <ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        <Border x:Name="ValidationErrorElement"
        Visibility="Collapsed"
        CornerRadius="1"
        BorderBrush="{StaticResource ControlOuterBorder_Invalid}"
        BorderThickness="1"
        Margin="1 1 2 2">
            <Popup x:Name="validationTooltip" Placement="Right" IsOpen="True" StaysOpen="True">
                <TextBlock Text="{TemplateBinding ErrorMessage}" Foreground="White" Background="Red"/>
            </Popup>
            <!--<Grid Height="12" HorizontalAlignment="Right" Margin="1 -4 -4 0" VerticalAlignment="Top" Width="12" Background="Transparent">
                <Path Fill="{StaticResource ControlOuterBorder_Invalid}" Margin="1 3 0 0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z"/>
                <Path Fill="{StaticResource ControlInnerBorder_Invalid}" Margin="1 3 0 0" Data="M 0,0 L2,0 L 8,6 L8,8"/>
            </Grid>-->
        </Border>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ValueStates">
                <VisualState x:Name="Normal"/>
                <VisualState x:Name="InvalidFocusedState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</ControlTemplate>
<Style TargetType="grid:GridViewEditorPresenter">
    <Setter Property="Template" Value="{StaticResource GridViewEditorPresenterTemplate}"/>
</Style>

I hope you find this helpful.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
band
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or