Skip to content

Commit

Permalink
Disable tally button if there are validation errors on the start or e…
Browse files Browse the repository at this point in the history
…nd post

text boxes.
Ensure that the text boxes remain enabled if they have validation errors.
  • Loading branch information
Kinematics committed May 30, 2015
1 parent 932b58b commit e8e9ccf
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions NetTally/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@
</Button.ToolTip>
</Button>
<TextBox x:Name="startPost" HorizontalAlignment="Left" Height="30" Margin="140,45,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="84"
Text="{Binding Path=CurrentItem.StartPost, ValidatesOnExceptions=True}" GotFocus="textEntry_GotFocus" PreviewMouseDown="textEntry_PreviewMouseDown" MaxLines="1"
IsEnabled="{Binding ElementName=tallyButton, Path=IsEnabled, Converter={StaticResource BoolConverter}, ConverterParameter=Normal, Mode=OneWay}">
Text="{Binding Path=CurrentItem.StartPost, ValidatesOnExceptions=True}" GotFocus="textEntry_GotFocus" PreviewMouseDown="textEntry_PreviewMouseDown" MaxLines="1">
<TextBox.IsEnabled>
<MultiBinding Converter="{StaticResource MultiBoolOrConverter}" Mode="OneWay">
<Binding ElementName="startPost" Path="(Validation.HasError)" Mode="OneWay" />
<Binding ElementName="tallyButton" Path="IsEnabled" Mode="OneWay" />
</MultiBinding>
</TextBox.IsEnabled>
<TextBox.ToolTip>
<ToolTip>
<StackPanel>
Expand All @@ -93,8 +98,13 @@
</TextBox.ToolTip>
</TextBox>
<TextBox x:Name="endPost" HorizontalAlignment="Left" Height="30" Margin="229,45,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="84"
Text="{Binding Path=CurrentItem.EndPost, ValidatesOnExceptions=True}" GotFocus="textEntry_GotFocus" PreviewMouseDown="textEntry_PreviewMouseDown" MaxLines="1"
IsEnabled="{Binding ElementName=tallyButton, Path=IsEnabled, Converter={StaticResource BoolConverter}, ConverterParameter=Normal, Mode=OneWay}">
Text="{Binding Path=CurrentItem.EndPost, ValidatesOnExceptions=True}" GotFocus="textEntry_GotFocus" PreviewMouseDown="textEntry_PreviewMouseDown" MaxLines="1">
<TextBox.IsEnabled>
<MultiBinding Converter="{StaticResource MultiBoolOrConverter}" Mode="OneWay">
<Binding ElementName="endPost" Path="(Validation.HasError)" Mode="OneWay" />
<Binding ElementName="tallyButton" Path="IsEnabled" Mode="OneWay" />
</MultiBinding>
</TextBox.IsEnabled>
<TextBox.ToolTip>
<ToolTip>
<StackPanel>
Expand Down Expand Up @@ -184,6 +194,8 @@
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource MultiBoolAndConverter}" Mode="OneWay">
<Binding ElementName="questList" Path="HasItems" Mode="OneWay" />
<Binding ElementName="startPost" Path="(Validation.HasError)" Converter="{StaticResource BoolConverter}" ConverterParameter="Invert" Mode="OneWay" />
<Binding ElementName="endPost" Path="(Validation.HasError)" Converter="{StaticResource BoolConverter}" ConverterParameter="Invert" Mode="OneWay" />
<Binding Path="TallyIsRunning" Converter="{StaticResource BoolConverter}" ConverterParameter="Invert" Mode="OneWay" />
</MultiBinding>
</Button.IsEnabled>
Expand Down

0 comments on commit e8e9ccf

Please sign in to comment.