IDataErrorInfo and tooltip

8 posts, 0 answers
  1. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 18 May 2010 Link to this post

    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.
  2. Kalin Milanov
    Admin
    Kalin Milanov avatar
    447 posts

    Posted 20 May 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 26 May 2010 Link to this post

    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?
  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 01 Jun 2010 Link to this post

    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.
  6. Gene
    Gene avatar
    64 posts
    Member since:
    Dec 2007

    Posted 07 Jun 2010 Link to this post

    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?
  7. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 10 Jun 2010 Link to this post

    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.
  8. Sam
    Sam avatar
    6 posts
    Member since:
    Oct 2010

    Posted 09 Nov 2010 Link to this post

    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?
  9. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 11 Nov 2010 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready