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

IDataErrorInfo and tooltip

7 Answers 412 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gene
Top achievements
Rank 1
Gene asked on 18 May 2010, 11:03 PM
What is the trick for binding Errors to the tooltips of GridViewDataColumns and GridViewComboboxColumns?

This is what I have and it only displays the default red line.

  <UserControl.Resources> 
        <Style TargetType="{x:Type telerik:GridViewColumn}">  
            <Style.Triggers> 
                <Trigger Property="Validation.HasError" Value="true">  
                    <Setter Property="ToolTip" 
                        Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>  
                </Trigger> 
            </Style.Triggers> 
        </Style> 
    </UserControl.Resources> 

 <telerik:RadGridView Name="wellsRadGridView" AutoGenerateColumns="False" ItemsSource="{Binding GetWells}" 
                             AddingNewDataItem="radGridView_AddingNewDataItem">  
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="WellID" DataMemberBinding="{Binding ID, ValidatesOnDataErrors=True, UpdateSourceTrigger=LostFocus}"/>  
                <telerik:GridViewDataColumn Header="X Coordinate" DataMemberBinding="{Binding XCoordinates}"  /> 
                <telerik:GridViewDataColumn Header="Y Coordinate" DataMemberBinding="{Binding YCoordinates}"  /> 
                <telerik:GridViewDataColumn Header="Top of Screen Elevation" DataMemberBinding="{Binding TopOfScreen, ValidatesOnDataErrors=True}"  /> 
                <telerik:GridViewDataColumn Header="Bottom of Screen Elevation" DataMemberBinding="{Binding BottomOfScreen, ValidatesOnDataErrors=True}"  /> 
                <telerik:GridViewDataColumn Header="Aquifier/Zone" DataMemberBinding="{Binding Zone}"  /> 
                <telerik:GridViewDataColumn Header="Functional Category" DataMemberBinding="{Binding FunctionalCategory}"  /> 
                <telerik:GridViewComboBoxColumn Header="Current Sampling Frequency" 
                                                DisplayMemberPath="Name"   
                                                SelectedValueMemberPath="ID" 
                                                DataMemberBinding="{Binding Frequency}" 
                                                ItemsSource="{Binding FrequencyCategories}"/>  
                <telerik:GridViewComboBoxColumn Header="Risk to Receptors"   
                                                DisplayMemberPath="Name" 
                                                SelectedValueMemberPath="ID" 
                                                DataMemberBinding="{Binding RiskReceptors}" 
                                                ItemsSource="{Binding RiskReceptors}" /> 
                <telerik:GridViewComboBoxColumn Header="Predictability of COC Concentrations"   
                                                DisplayMemberPath="Name" 
                                                SelectedValueMemberPath="ID" 
                                                DataMemberBinding="{Binding Predictability}"    
                                                ItemsSource="{Binding Predictability}" /> 
                <telerik:GridViewDataColumn Header="Notes" DataMemberBinding="{Binding Notes}"  /> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 


thanks in advance.
Gene.

7 Answers, 1 is accepted

Sort by
0
Kalin Milanov
Telerik team
answered on 20 May 2010, 12:56 PM
Hi Gene,

IDataErrorInfo is used for data validation and as such your editor control (TextBox / ComboBox), not the column, will display a proper invalid state and show you the errors. Unfortunately the WPF and SL validation states differ and as such there is no way to achieve SL-like validation in WPF just by styling the controls.

Regards,
Kalin Milanov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gene
Top achievements
Rank 1
answered on 26 May 2010, 07:21 PM
So to display validation errors to the user we should display the message on the screen?  Can we still use the IDataErrorInfo to find the errors?  If so, do you have any examples?
0
Yavor Georgiev
Telerik team
answered on 01 Jun 2010, 10:59 AM
Hello Gene,

 Here's how you can bind the error message from the IDataErrorInfo interface to the tooltip of a UI element (taken from here):

<Style TargetType="{x:Type TextBox}">
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="true">
            <Setter Property="ToolTip"
        Value="{Binding RelativeSource={RelativeSource Self},
               Path=(Validation.Errors)[0].ErrorContent}"/>
        </Trigger>
    </Style.Triggers>
</Style>

Sincerely yours,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gene
Top achievements
Rank 1
answered on 07 Jun 2010, 10:09 PM
Is there a way to bind it to the error message on the cell?

I was looking at your cell template validation example and the GridViewCellValidatingEventArgs has an ErrorMessage property.

AND

Is there a way to leverage the IDataErrorInfo interface with RowValidation?
0
Nedyalko Nikolov
Telerik team
answered on 10 Jun 2010, 08:52 PM
Hi Gene,

Generally RadGridView has two validation layers UI and Data. IDataErrorInfo is used by data layer validation and RadGridView's role here is just to update underlying value via binding at the right moment. Error validation template comes from WPF framework. Unfortunately the default WPF validation (error) template is a thin red line around the control. Good news about WPF is that you can easily restyle any control (also validation error template). You can take a look at following posts about how you can change validation error template.

link1, link2, link3

If you want to use GridViewCellValidatingEventArgs.ErrorMessage you have to use UI validation, after all IDataErrorInfo implementation logic also can be implemented within RadGridView.CellValidating event handler. You can take a look at my blog post in case you missed it for more information about cell validation.

I hope this will help.

Regards,
Nedyalko Nikolov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sam
Top achievements
Rank 1
answered on 09 Nov 2010, 06:29 AM
I am running into the same problem while switching from Silverlight to WPF; the "free" validation tooltips for editor controls aren't present anymore.  Isn't there a way to grab the silverlight styles from blend, and make them implicit styles in WPF so that the GridViewDataColumns in edit mode will pick up the seksi, animated validation tooltips?
0
Nedyalko Nikolov
Telerik team
answered on 11 Nov 2010, 05:38 PM
Hello Sam,

Generally we've left the default error validation templates. Just for WPF validation templates are not so "sexy". You can take a look at this link for more information how to customize validation template.

Sincerely yours,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Gene
Top achievements
Rank 1
Answers by
Kalin Milanov
Telerik team
Gene
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Nedyalko Nikolov
Telerik team
Sam
Top achievements
Rank 1
Share this question
or