In MainWindow.xaml
I am trying to use two StaticResource
elements to define the thickness of the border of a TextBox in a Grid. I cannot seem to use the StaticResource
more than once in a BorderThickness
specification.
The code snippets which work are,
xmlns:syw="clr-namespace:System.Windows;assembly=PresentationFramework"
<Window.Resources>
<syw:Thickness x:Key="thick">5.0</syw:Thickness>
<syw:Thickness x:Key="thin">1.0</syw:Thickness>
</Window.Resources>
After the number of rows and columns are defined, and still within the <Grid>
section,
<TextBox Name="c00" Grid.Row="1" Grid.Column="1" BorderBrush="Black" BorderThickness="{StaticResource ResourceKey=thick}"/>
<TextBox Name="c01" Grid.Row="2" Grid.Column="2" BorderBrush="Black" BorderThickness="5.0, 5.0, 1.0, 1.0"/>
This code complies and displays two TextBoxes, the first with the same border thickness on all four sides of the TextBox, the second with one thickness for the left and top sides, and a second thickness for the right and bottom sides of the TextBox.
What I want to be able to do is use the StaticResource multiple times in place of the numbers in the second line immediately above since I have a lot of TextBoxes and want to be able to change the border thicknesses by changing a couple of numbers, viz., thick
and thin
. However, when I try,
<TextBox Name="c00" Grid.Row="1" Grid.Column="1" BorderBrush="Black"
BorderThickness="{StaticResource ResourceKey=thick},{StaticResource ResourceKey=thick},{StaticResource ResourceKey=thin},{StaticResource ResourceKey=thin}"/>
the editor indicates that the comma is unexpected at that position and won't compile.
Am I just formatting this incorrectly?