RadDatePicker Culture defiend in style

2 posts, 0 answers
  1. Josip Jaic
    Josip Jaic avatar
    19 posts
    Member since:
    Jul 2008

    Posted 29 Jul 2009 Link to this post

    Hi,

    Today i run into problem with RadDatePicker (latest dev Q2 2009)
    which took me some time to solve

    This is working OK

     

     

    <telerikInput:RadDatePicker

     

     

    x:Name="datePickerHBC_CreateDate"

     

     

    Style="{StaticResource DefaultDateTimePicker}"

     

     

    SelectionChanged="datePickerHBC_CreateDate_SelectionChanged"

     

     

    IsEnabled="False"

     

     

    Culture="hr-HR"

     

     

    />

     

     

     

    <Style x:Key="DefaultDateTimePicker" TargetType="telerikInput:RadDatePicker">

     

     

     

     

     

     

    <Setter Property="HorizontalAlignment" Value="Left"/>

     

     

     

     

     

     

    <Setter Property="VerticalAlignment" Value="Center"/>

     

     

     

     

     

     

    <Setter Property="Width" Value="90"/>

     

     

     

     

     

     

    <Setter Property="Height" Value="20"/>

     

     

     

     

     

     

    <Setter Property="Margin" Value="1"/>

     

     

     

    </Style>

    But if you delete line Culture="hr-HR"
    and add setter in style
    <Setter Property="Culture" Value="hr-HR"/> 
     this is throwing unhandled exception (which did not point to error)

     [Line: 0 Position: 0]
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.ConvertStringToTypedCValue(IntPtr pContext, UInt32 cClrTypeName, String clrTypeName, UInt32 cValue, String value, CValue& outVal, Int32& typeIndex)
       at MS.Internal.SilverlightTypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
       at MS.Internal.FrameworkCallbacks.SetValueCustom(IntPtr nativeRoot, IntPtr nativeTarget, UInt32 propertyId, String attrValue, CValue& propertyValue, Int32 typeIndex, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)


    Hope this is helping someone not to make same mistake as I did

     

  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 31 Jul 2009 Link to this post

    Hello Josip Jaic,

    For now it is not possible to set a Culture in the Setter of a style in the control, because the Silverlight parser is trying to set the string as a culture and not as a CultureInfo. Whereas if you set the culture directly in the control as a value, it is implicitly converted as a CultureInfo.

    Regards,
    Kaloyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top