Home Forums WPF controls Xceed DataGrid for WPF CellErrorStyle

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24050 |

    I have tried create a Custom Error Style but the ToolTip refuses to be raised. I have followed the typical Binding on the Value of the Tooltip Property …

    1. If the Value is set to a text value “Error” it is displayed.
    2. If I use the default CellErrorStyle then the correct Error Message from the Validation Routine is displayed.
    3. I even tried using a Trigger which revealed even more odd results – it only displayed a text value (e.g. “Error”) when testing the Property “Validation.HasError” was found to be False.

    My code…I’ll append the Trigger version for completeness.

    <Style x:Key=”Cell_Error_Style” TargetType=”{x:Type xcdg:DataCell}”>
    <Setter Property=”Foreground” Value=”Black”/>
    <Setter Property=”Background” Value=”Salmon”/>
    <Setter
    Property=”ToolTip”
    Value=”{Binding RelativeSource={x:Static RelativeSource.Self},Path=(Validation.Errors)[0].ErrorContent}”/>
    </Style>

    With Trigger…..the Value=”This oddly enough gets displayed” but of cousre when I use the Binding syntax is doesn’t.

    <Style x:Key=”Cell_Error_Style” TargetType=”{x:Type xcdg:DataCell}”>
    <Setter Property=”Foreground” Value=”Black”/>
    <Setter Property=”Background” Value=”Salmon”/>
    <Style.Triggers>
    <Trigger Property=”Validation.HasError” Value=”True”>
    <Setter Property=”ToolTip”
    Value=”Error”/>
    </Trigger>
    <Trigger Property=”Validation.HasError” Value=”False”>
    <Setter Property=”ToolTip”
    Value=”This oddly enough gets displayed”/>
    </Trigger>
    </Style.Triggers>
    </Style>

    Any ideas ..

    Cheers.

    Imported from legacy forums. Posted by Desmond (had 1085 views)

    User (Old forums)
    Member
    Post count: 23064

    Anybody ???

    I thought at one stage it might have been a problem in that the Validation routines were in a different assembly but its still failing to ‘ToolTip’ when I moved the routines locally.

    However..I should have included this form the Immediate window whilst in debug…

    Why would it be looking for a ” value ?

    PLEASE HELP !!!

    System.Windows.Data Error: 12 : Cannot get ” value (type ‘ValidationError’) from ‘(Validation.Errors)’ (type ‘ReadOnlyObservableCollection`1′). BindingExpression:Path=(0).[0].ErrorContent; DataItem=’DataCell’ (Name=”); target element is ‘DataCell’ (Name=”); target property is ‘ToolTip’ (type ‘Object’) TargetInvocationException:’System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
    at System.ThrowHelper.ThrowArgumentOutOfRangeException()
    at System.Collections.Generic.List`1.get_Item(Int32 index)
    at System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
    at System.Collections.ObjectModel.ReadOnlyCollection`1.get_Item(Int32 index)
    — End of inner exception stack trace —
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
    at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
    at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)’

    Imported from legacy forums. Posted by Desmond (had 562 views)

    Xceed Support
    Member
    Post count: 5658

    The property you should be displaying is ValidationError.ErrorContent. The current DataContext is the parent DataRow, so you have to make sure to change the context to “self”, which represents the cell. For example:

    <code>
    <Style x:Key=”cellerrorstyle” TargetType=”{x:Type xcdg:DataCell}”>
    <Setter Property=”Background” Value=”HotPink”/>
    <Setter Property=”Foreground” Value=”White”/>
    <Setter Property=”ToolTip” Value=”{Binding RelativeSource={RelativeSource Self}, Path=ValidationError.ErrorContent}”/>
    </Style>
    </code>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 472 views)

    User (Old forums)
    Member
    Post count: 23064

    Many thanks Jenny…

    Marvelous…that simple….

    Cheers,

    Dezzz.

    Imported from legacy forums. Posted by Desmond (had 373 views)

    Xceed Support
    Member
    Post count: 5658

    Just remember: if you don’t use hot pink, it won’t work 😉

    Imported from legacy forums. Posted by Jenny [Xceed] (had 4428 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.