Skip to content

Commit d4b3bbc

Browse files
committed
inlined numberpicker control to get the bindings to work
1 parent fac8d17 commit d4b3bbc

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Rubberduck.Core/UI/Settings/AutoCompleteSettings.xaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,24 @@
112112
Content="{Resx ResxName=Rubberduck.Resources.Settings.AutoCompletesPage, Key=ConcatVbNewLine}" />
113113

114114
<Label Margin="15,0,15,0" Content="{Resx ResxName=Rubberduck.Resources.Settings.AutoCompletesPage, Key=MaxConcatLines}" />
115-
<controls:NumberPicker Margin="15,0,15,0" DataContext="{Binding Path=DataContext, Mode=OneWay, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type settings:AutoCompleteSettings}}}"
115+
<StackPanel Orientation="Horizontal" Margin="15,0,15,0">
116+
<TextBox Margin="5,5,0,5" Height="20" Width="50" Text="{Binding ConcatMaxLines, Mode=TwoWay, StringFormat=\{0:D\}, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" VerticalAlignment="Top" VerticalContentAlignment="Center" />
117+
<StackPanel Margin="0,5" >
118+
<Button Height="10" Width="20" Command="{Binding IncrementMaxConcatLinesCommand}">
119+
<TextBlock Text="˄" FontSize="10" Margin="0,-4,0,0"/>
120+
</Button>
121+
<Button Height="10" Width="20" Command="{Binding DecrementMaxConcatLinesCommand}">
122+
<TextBlock Text="˅" FontSize="10" Margin="0,-3,0,0"/>
123+
</Button>
124+
</StackPanel>
125+
</StackPanel>
126+
127+
<!--<controls:NumberPicker Margin="15,0,15,0" DataContext="{Binding Path=DataContext, Mode=OneWay, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type settings:AutoCompleteSettings}}}"
116128
NumValue="{Binding Path=DataContext.ConcatMaxLines, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
117129
MinNumber="{Binding Path=DataContext.ConcatMaxLinesMinValue, RelativeSource={RelativeSource Self}}"
118130
MaxNumber="{Binding Path=DataContext.ConcatMaxLinesMaxValue, RelativeSource={RelativeSource Self}}">
119131
120-
</controls:NumberPicker>
132+
</controls:NumberPicker>-->
121133
<Label Margin="10"
122134
Content="{Resx ResxName=Rubberduck.Resources.Settings.AutoCompletesPage, Key=BlockCompletion}"
123135
FontWeight="Bold" />

Rubberduck.Core/UI/Settings/AutoCompleteSettingsViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using NLog;
1+
using System.Windows.Input;
2+
using NLog;
23
using Rubberduck.Resources;
34
using Rubberduck.Resources.Settings;
45
using Rubberduck.Settings;
@@ -14,8 +15,21 @@ public AutoCompleteSettingsViewModel(Configuration config)
1415
TransferSettingsToView(config.UserSettings.AutoCompleteSettings);
1516
ExportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ExportSettings());
1617
ImportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ImportSettings());
18+
19+
IncrementMaxConcatLinesCommand = new DelegateCommand(null, ExecuteIncrementMaxConcatLines, CanExecuteIncrementMaxConcatLines);
20+
DecrementMaxConcatLinesCommand = new DelegateCommand(null, ExecuteDecrementMaxConcatLines, CanExecuteDecrementMaxConcatLines);
1721
}
1822

23+
public ICommand IncrementMaxConcatLinesCommand { get; }
24+
25+
private bool CanExecuteIncrementMaxConcatLines(object parameter) => ConcatMaxLines < ConcatMaxLinesMaxValue;
26+
private void ExecuteIncrementMaxConcatLines(object parameter) => ConcatMaxLines++;
27+
28+
public ICommand DecrementMaxConcatLinesCommand { get; }
29+
30+
private bool CanExecuteDecrementMaxConcatLines(object parameter) => ConcatMaxLines > ConcatMaxLinesMinValue;
31+
private void ExecuteDecrementMaxConcatLines(object parameter) => ConcatMaxLines--;
32+
1933
public void SetToDefaults(Configuration config)
2034
{
2135
TransferSettingsToView(config.UserSettings.AutoCompleteSettings);

0 commit comments

Comments
 (0)