Case
I've defined a series of GridLenghts as a resource in my WPF Window:
<w:GridLength x:Key="ScrollBarRowHeight">17</w:GridLength>
Since this scrollbar height is variable dependent on the operating system used, I'd like to refactor this line of code to use the static parameter value SystemParameters.HorizontalScrollBarHeight.
Problem
I've tried both these lines:
<w:GridLength x:Key="ScrollBarRowHeight"><DynamicResource Key="{x:Static System.Windows.SystemParameters.CaptionHeightKey}" /></w:GridLength>
<w:GridLength x:Key="ScrollBarRowHeight"><x:Static x:Key="System.Windows.SystemParameters.HorizontalScrollBarHeight" /></w:GridLength>
Resulting both in the same compile-time error:
Cannot add content to object of type 'System.Windows.GridLength'.
Questions
- Is it possible to do this declaratively in XAML?
- If yes, how?
- If no, is there a neat solution which does not include code-behind?
Thanks in advance!