Exception on FontWeight in row style

2 posts, 1 answers
  1. Jerome
    Jerome avatar
    3 posts
    Member since:
    Mar 2012

    Posted 11 Mar 2013 Link to this post

    I have the following style applied to my TreeListView component, using the static resources below:
    <sw:FontWeight x:Key="NormalWeight">Normal</sw:FontWeight>
    <sw:FontWeight x:Key="BoldWeight">Bold</sw:FontWeight>
    <sw:FontStyle x:Key="NormalStyle">Normal</sw:FontStyle>

    <Style x:Key="TemplateRow" TargetType="telerik:TreeListViewRow">
      <Setter Property="FontSize" Value="10"/>
      <Setter Property="FontStyle"
                   Value="{Binding Path=MyProperty1,
                              Converter={StaticResource BooleanToFontEmphasisConverter},
                              FallbackValue={StaticResource NormalStyle},
                              TargetNullValue={StaticResource NormalStyle}}" />
      <Setter Property="FontWeight"
                   Value="{Binding Path=MyProperty2,
                              Converter={StaticResource BooleanToFontWeightConverter},
                              FallbackValue={StaticResource NormalWeight},
                              TargetNullValue={StaticResource NormalWeight}}" />
      <Setter Property="IsExpanded" Value="{Binding Expanded, Mode=TwoWay}" />
      <Setter Property="IsSelected" Value="{Binding Selected, Mode=TwoWay}" />

    The FontStyle style is applied as expected to each row, but the FontWeight causes an exception whenever either MyProperty2 changes, or when a node is folded closed. The exception is a TargetInvocationException raised from an ArgumentOutOfRange exception
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Delegate.DynamicInvokeImpl(Object[] args)
    at System.Delegate.DynamicInvoke(Object[] args)
    at TemplatesListTreexaml.BindingOperation(Object BindingState, Int32 , Action )
    The inner exception says that parameter "weight" is out of range
    à System.Windows.FontWeights.EnsureFontWeight(FontWeightType weight)
    at MS.Internal.XcpImports.TryConvertPseudoEnum(RuntimeTypeHandle typeHandle, Int32 value, Object& result)
    at MS.Internal.XcpImports.ConvertCValueForManagedWithType(Type propertyType, CValue& outVal, Int32 outDOType, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
    at MS.Internal.XcpImports.GetValue(IManagedPeerBase managedPeer, DependencyProperty property)
    at System.Windows.DependencyObject.GetOldValue(DependencyProperty property, EffectiveValueEntry& oldEntry)
    at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
    at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
    at System.Windows.Data.BindingExpression.SendDataToTarget()
    at System.Windows.Data.BindingExpression.SourceAcquired()
    at System.Windows.Data.Debugging.BindingBreakPoint.<>c__DisplayClass4.<BreakOnSharedType>b__3()

    In addition, when I substitute MyProperty2 with MyProperty1 in the FontWeight style, the error still occurs.
    Debugger breakpoint in the converter, however, shows tht it returns either FontWeights.Bold or FontWeights.Normal.
  2. Answer
    Yordanka avatar
    634 posts

    Posted 12 Mar 2013 Link to this post

    Hi Jerome,

    Thank you for the report.

    We reproduced the exception and it was fixed immediately. The fix for it will be part of the next internal build on Monday.

    I've updated your Telerik points.
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top