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

Exception on FontWeight in row style

1 Answer 94 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Jerome
Top achievements
Rank 1
Jerome asked on 11 Mar 2013, 05:02 PM
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}" />
</Style>

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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Yordanka
Telerik team
answered on 12 Mar 2013, 03:28 PM
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.
 
Greetings,
Yordanka
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeListView
Asked by
Jerome
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
Share this question
or