Skip to content

Commit 80f153b

Browse files
authored
Merge pull request #53 from jholzer/master
Fixes "FormatString not working with custom texts", "Control not scaling correctly with HorizontalAlignment set to 'Stretch'"
2 parents 361a188 + dd682fe commit 80f153b

28 files changed

+292
-369
lines changed

source/Demo/UpDownDemoLib/ViewModels/DecimalUpDownViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ decimal largeStepSize
2929
base.MaximumValue = maximumValue;
3030
base.StepSize = stepSize;
3131
base.LargeStepSize = largeStepSize;
32+
33+
// "decimal" does not support format string "D" as set in base class
34+
FormatString = "F4";
3235
}
3336

3437
/// <summary>

source/Demo/UpDownDemoLib/ViewModels/DoubleUpDownViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ double largestepSize
2929
base.MaximumValue = maximumValue;
3030
base.StepSize = stepSize;
3131
base.LargeStepSize = largestepSize;
32+
33+
FormatString = "F4";
3234
}
3335

3436
/// Method determine whether two objects of type {T} are equal.

source/Demo/UpDownDemoLib/ViewModels/FloatUpDownViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ float largeStepSize
2929
base.MaximumValue = maximumValue;
3030
base.StepSize = stepSize;
3131
base.LargeStepSize = largeStepSize;
32+
33+
FormatString = "F4";
3234
}
3335

3436
/// Method determine whether two objects of type {T} are equal.

source/Demo/UpDownDemoLib/Views/ByteUpDownDemo.xaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
Grid.ColumnSpan="2">
1616
<Grid.ColumnDefinitions>
1717
<ColumnDefinition Width="Auto" />
18-
<ColumnDefinition Width="*" />
18+
<ColumnDefinition Width="5" />
19+
<ColumnDefinition Width="*" />
1920
</Grid.ColumnDefinitions>
2021
<Grid.RowDefinitions>
2122
<RowDefinition Height="auto" />
@@ -25,9 +26,8 @@
2526
<cntrl:ByteUpDown
2627
Name="SampleUpDown"
2728
Grid.Column="0"
28-
Grid.ColumnSpan="2"
2929
Margin="3"
30-
HorizontalAlignment="Left"
30+
HorizontalAlignment="Stretch"
3131
VerticalAlignment="Top"
3232
HorizontalContentAlignment="{Binding HzntalContentAlignment}"
3333
DisplayLength="5"
@@ -43,10 +43,9 @@
4343
ToolTip="{Binding ToolTip, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
4444
Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
4545

46-
<Grid
47-
Grid.Row="1"
48-
Grid.Column="1"
49-
Margin="12,3,3,3">
46+
<GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="5" HorizontalAlignment="Stretch" />
47+
48+
<Grid Grid.Row="0" Grid.Column="2" Margin="12,3,3,3">
5049
<Grid.Resources>
5150
<conv:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
5251
</Grid.Resources>
@@ -259,7 +258,20 @@
259258
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Shift}" />
260259
</StackPanel>
261260
</Border>
262-
</StackPanel>
261+
262+
<Border
263+
Margin="0,3"
264+
BorderBrush="Gray"
265+
BorderThickness="1">
266+
<StackPanel Margin="3">
267+
268+
<Label Content="FormatString" />
269+
<TextBox Text="{Binding FormatString}" />
270+
271+
</StackPanel>
272+
273+
</Border>
274+
</StackPanel>
263275
</GroupBox>
264276
</Grid>
265277
</Grid>

source/Demo/UpDownDemoLib/Views/DecimalUpDownDemo.xaml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
Grid.ColumnSpan="2">
1616
<Grid.ColumnDefinitions>
1717
<ColumnDefinition Width="Auto" />
18-
<ColumnDefinition Width="*" />
18+
<ColumnDefinition Width="5" />
19+
<ColumnDefinition Width="*" />
1920
</Grid.ColumnDefinitions>
2021
<Grid.RowDefinitions>
2122
<RowDefinition Height="auto" />
@@ -25,12 +26,12 @@
2526
<cntrl:DecimalUpDown
2627
Name="SampleUpDown"
2728
Grid.Column="0"
28-
Grid.ColumnSpan="2"
2929
Margin="3"
30-
HorizontalAlignment="Left"
30+
HorizontalAlignment="Stretch"
3131
VerticalAlignment="Top"
3232
HorizontalContentAlignment="{Binding HzntalContentAlignment}"
3333
DisplayLength="10"
34+
FormatString="{Binding FormatString, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
3435
IsDisplayLengthFixed="True"
3536
IsMouseDragEnabled="{Binding ElementName=IsMouseDragEnabledCheckBox, Path=IsChecked}"
3637
IsReadOnly="False"
@@ -42,10 +43,9 @@
4243
ToolTip="{Binding ToolTip, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
4344
Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
4445

45-
<Grid
46-
Grid.Row="1"
47-
Grid.Column="1"
48-
Margin="12,3,3,3">
46+
<GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="5" HorizontalAlignment="Stretch" />
47+
48+
<Grid Grid.Row="0" Grid.Column="2" Margin="12,3,3,3">
4949
<Grid.Resources>
5050
<conv:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
5151
</Grid.Resources>
@@ -250,7 +250,20 @@
250250
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Shift}" />
251251
</StackPanel>
252252
</Border>
253-
</StackPanel>
253+
254+
<Border
255+
Margin="0,3"
256+
BorderBrush="Gray"
257+
BorderThickness="1">
258+
<StackPanel Margin="3">
259+
260+
<Label Content="FormatString" />
261+
<TextBox Text="{Binding FormatString}" />
262+
263+
</StackPanel>
264+
265+
</Border>
266+
</StackPanel>
254267
</GroupBox>
255268
</Grid>
256269
</Grid>

source/Demo/UpDownDemoLib/Views/DoubleUpDownDemo.xaml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
Grid.ColumnSpan="2">
1616
<Grid.ColumnDefinitions>
1717
<ColumnDefinition Width="Auto" />
18-
<ColumnDefinition Width="*" />
18+
<ColumnDefinition Width="5" />
19+
<ColumnDefinition Width="*" />
1920
</Grid.ColumnDefinitions>
2021
<Grid.RowDefinitions>
2122
<RowDefinition Height="auto" />
@@ -25,13 +26,12 @@
2526
<cntrl:DoubleUpDown
2627
Name="SampleUpDown"
2728
Grid.Column="0"
28-
Grid.ColumnSpan="2"
2929
Margin="3"
30-
HorizontalAlignment="Left"
30+
HorizontalAlignment="Stretch"
3131
VerticalAlignment="Top"
3232
HorizontalContentAlignment="{Binding HzntalContentAlignment}"
3333
DisplayLength="7"
34-
FormatString="F4"
34+
FormatString="{Binding FormatString, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
3535
IsDisplayLengthFixed="True"
3636
IsMouseDragEnabled="{Binding ElementName=IsMouseDragEnabledCheckBox, Path=IsChecked}"
3737
IsReadOnly="False"
@@ -43,10 +43,9 @@
4343
ToolTip="{Binding ToolTip, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
4444
Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
4545

46-
<Grid
47-
Grid.Row="1"
48-
Grid.Column="1"
49-
Margin="12,3,3,3">
46+
<GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="5" HorizontalAlignment="Stretch" />
47+
48+
<Grid Grid.Row="0" Grid.Column="2" Margin="12,3,3,3">
5049
<Grid.Resources>
5150
<conv:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
5251
</Grid.Resources>
@@ -248,7 +247,19 @@
248247
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Shift}" />
249248
</StackPanel>
250249
</Border>
251-
</StackPanel>
250+
<Border
251+
Margin="0,3"
252+
BorderBrush="Gray"
253+
BorderThickness="1">
254+
<StackPanel Margin="3">
255+
256+
<Label Content="FormatString" />
257+
<TextBox Text="{Binding FormatString}" />
258+
259+
</StackPanel>
260+
261+
</Border>
262+
</StackPanel>
252263
</GroupBox>
253264
</Grid>
254265
</Grid>

source/Demo/UpDownDemoLib/Views/FloatUpDownDemo.xaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
Grid.ColumnSpan="2">
1616
<Grid.ColumnDefinitions>
1717
<ColumnDefinition Width="Auto" />
18-
<ColumnDefinition Width="*" />
18+
<ColumnDefinition Width="5" />
19+
<ColumnDefinition Width="*" />
1920
</Grid.ColumnDefinitions>
2021
<Grid.RowDefinitions>
2122
<RowDefinition Height="auto" />
@@ -25,12 +26,12 @@
2526
<cntrl:FloatUpDown
2627
Name="SampleUpDown"
2728
Grid.Column="0"
28-
Grid.ColumnSpan="2"
2929
Margin="3"
30-
HorizontalAlignment="Left"
30+
HorizontalAlignment="Stretch"
3131
VerticalAlignment="Top"
3232
HorizontalContentAlignment="{Binding HzntalContentAlignment}"
3333
DisplayLength="5"
34+
FormatString="{Binding FormatString, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
3435
IsDisplayLengthFixed="True"
3536
IsMouseDragEnabled="{Binding ElementName=IsMouseDragEnabledCheckBox, Path=IsChecked}"
3637
IsReadOnly="False"
@@ -42,10 +43,9 @@
4243
ToolTip="{Binding ToolTip, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
4344
Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
4445

45-
<Grid
46-
Grid.Row="1"
47-
Grid.Column="1"
48-
Margin="12,3,3,3">
46+
<GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="5" HorizontalAlignment="Stretch" />
47+
48+
<Grid Grid.Row="0" Grid.Column="2" Margin="12,3,3,3">
4949
<Grid.Resources>
5050
<conv:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
5151
</Grid.Resources>
@@ -250,7 +250,19 @@
250250
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Shift}" />
251251
</StackPanel>
252252
</Border>
253-
</StackPanel>
253+
<Border
254+
Margin="0,3"
255+
BorderBrush="Gray"
256+
BorderThickness="1">
257+
<StackPanel Margin="3">
258+
259+
<Label Content="FormatString" />
260+
<TextBox Text="{Binding FormatString}" />
261+
262+
</StackPanel>
263+
264+
</Border>
265+
</StackPanel>
254266
</GroupBox>
255267
</Grid>
256268
</Grid>

source/Demo/UpDownDemoLib/Views/LongUpDownDemo.xaml

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
Grid.ColumnSpan="2">
1616
<Grid.ColumnDefinitions>
1717
<ColumnDefinition Width="Auto" />
18-
<ColumnDefinition Width="*" />
18+
<ColumnDefinition Width="5" />
19+
<ColumnDefinition Width="*" />
1920
</Grid.ColumnDefinitions>
2021
<Grid.RowDefinitions>
2122
<RowDefinition Height="auto" />
@@ -25,10 +26,9 @@
2526
<cntrl:LongUpDown
2627
Name="SampleUpDown"
2728
Grid.Column="0"
28-
Grid.ColumnSpan="2"
2929
Margin="3"
30-
HorizontalAlignment="Left"
31-
VerticalAlignment="Top"
30+
HorizontalAlignment="Stretch"
31+
VerticalAlignment="Top"
3232
HorizontalContentAlignment="{Binding HzntalContentAlignment}"
3333
DisplayLength="5"
3434
FormatString="{Binding FormatString, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
@@ -44,10 +44,9 @@
4444
ToolTip="{Binding ToolTip, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
4545
Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
4646

47-
<Grid
48-
Grid.Row="1"
49-
Grid.Column="1"
50-
Margin="12,3,3,3">
47+
<GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="5" HorizontalAlignment="Stretch" />
48+
49+
<Grid Grid.Row="0" Grid.Column="2" Margin="12,3,3,3">
5150
<Grid.Resources>
5251
<conv:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
5352
</Grid.Resources>
@@ -230,35 +229,47 @@
230229
ToolTip="Toggles whether a validation indicator is shown in the upper left corner of the control." />
231230
</StackPanel>
232231

233-
<Border
232+
<Border
234233
Margin="0,3"
235234
BorderBrush="Gray"
236235
BorderThickness="1">
237-
<StackPanel xmlns:input="System.Windows.Input" Margin="3">
238-
<StackPanel.Resources>
239-
<conv:EnumMatchToBooleanConverter x:Key="enumConverter" />
240-
</StackPanel.Resources>
236+
<StackPanel xmlns:input="System.Windows.Input" Margin="3">
237+
<StackPanel.Resources>
238+
<conv:EnumMatchToBooleanConverter x:Key="enumConverter" />
239+
</StackPanel.Resources>
241240

242241

243-
<TextBlock Margin="3" Text="Press this key to accelerate increments/decrements when scrolling with mouse wheel." />
242+
<TextBlock Margin="3" Text="Press this key to accelerate increments/decrements when scrolling with mouse wheel." />
244243

245-
<RadioButton
244+
<RadioButton
246245
Margin="3"
247246
Content="Alt"
248247
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Alt}" />
249248

250-
<RadioButton
249+
<RadioButton
251250
Margin="3"
252251
Content="Control"
253252
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Control}" />
254253

255-
<RadioButton
254+
<RadioButton
256255
Margin="3"
257256
Content="Shift"
258257
IsChecked="{Binding Path=AccelModifierKey, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Shift}" />
259-
</StackPanel>
260-
</Border>
261-
</StackPanel>
258+
</StackPanel>
259+
</Border>
260+
<Border
261+
Margin="0,3"
262+
BorderBrush="Gray"
263+
BorderThickness="1">
264+
<StackPanel Margin="3">
265+
266+
<Label Content="FormatString" />
267+
<TextBox Text="{Binding FormatString}" />
268+
269+
</StackPanel>
270+
271+
</Border>
272+
</StackPanel>
262273
</GroupBox>
263274
</Grid>
264275
</Grid>

0 commit comments

Comments
 (0)