Skip to content

Commit 78588c7

Browse files
committed
removed the additional vliadtion rule, as it wasn't really necessary. In fact, for the demo it is a bit better to binf an editable combo box's Text preoprty...as it's editable...it could be any value
1 parent d3e797f commit 78588c7

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

MainDemo.Wpf/Domain/NotNullValidationRule.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

MainDemo.Wpf/Domain/TextFieldsViewModel.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ namespace MaterialDesignColors.WpfExample.Domain
1313
public class TextFieldsViewModel : INotifyPropertyChanged
1414
{
1515
private string _name;
16-
private int _selectedValueOne;
17-
private int? _selectedValueTwo;
16+
private int? _selectedValueOne;
17+
private string _selectedTextTwo;
1818

1919
public TextFieldsViewModel()
2020
{
2121
LongListToTestComboVirtualization = new List<int>(Enumerable.Range(0, 1000));
2222

2323
SelectedValueOne = LongListToTestComboVirtualization.Skip(2).First();
24-
SelectedValueTwo = null;
24+
SelectedTextTwo = null;
2525
}
2626

2727
public string Name
@@ -33,21 +33,21 @@ public string Name
3333
}
3434
}
3535

36-
public int SelectedValueOne
36+
public int? SelectedValueOne
3737
{
3838
get { return _selectedValueOne; }
3939
set
4040
{
4141
this.MutateVerbose(ref _selectedValueOne, value, RaisePropertyChanged());
4242
}
43-
}
43+
}
4444

45-
public int? SelectedValueTwo
45+
public string SelectedTextTwo
4646
{
47-
get { return _selectedValueTwo; }
47+
get { return _selectedTextTwo; }
4848
set
4949
{
50-
this.MutateVerbose(ref _selectedValueTwo, value, RaisePropertyChanged());
50+
this.MutateVerbose(ref _selectedTextTwo, value, RaisePropertyChanged());
5151
}
5252
}
5353

MainDemo.Wpf/MaterialDesignDemo.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
<Compile Include="Domain\DemoItem.cs" />
9494
<Compile Include="Domain\DialogsViewModel.cs" />
9595
<Compile Include="Domain\ListFieldsViewModel.cs" />
96-
<Compile Include="Domain\NotNullValidationRule.cs" />
9796
<Compile Include="Domain\Sample4Dialog.xaml.cs">
9897
<DependentUpon>Sample4Dialog.xaml</DependentUpon>
9998
</Compile>

MainDemo.Wpf/TextFields.xaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<ComboBox.SelectedItem>
134134
<Binding Path="SelectedValueOne" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
135135
<Binding.ValidationRules>
136-
<domain1:NotNullValidationRule ValidatesOnTargetUpdated="True"/>
136+
<domain1:NotEmptyValidationRule ValidatesOnTargetUpdated="True"/>
137137
</Binding.ValidationRules>
138138
</Binding>
139139
</ComboBox.SelectedItem>
@@ -149,13 +149,13 @@
149149
VerticalAlignment="Bottom"
150150
IsEditable="True"
151151
ItemsSource="{Binding LongListToTestComboVirtualization}">
152-
<ComboBox.SelectedItem>
153-
<Binding Path="SelectedValueTwo" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
152+
<ComboBox.Text>
153+
<Binding Path="SelectedTextTwo" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
154154
<Binding.ValidationRules>
155-
<domain1:NotNullValidationRule ValidatesOnTargetUpdated="True"/>
155+
<domain1:NotEmptyValidationRule ValidatesOnTargetUpdated="True"/>
156156
</Binding.ValidationRules>
157157
</Binding>
158-
</ComboBox.SelectedItem>
158+
</ComboBox.Text>
159159
<ComboBox.ItemsPanel>
160160
<ItemsPanelTemplate>
161161
<VirtualizingStackPanel />

0 commit comments

Comments
 (0)