Skip to content

Instantly share code, notes, and snippets.

@dfmmalaw
dfmmalaw / RetailSaleAddNewCustomerView.xaml
Last active July 10, 2018 17:49
I added validation to an email address form field. Instead of doing the validation on the CSLA object we decided to put the validation in the viewmodel. This decision was made due to it being lower risk than involving the CSLS properties in the valid
<StackPanel Grid.Row="3" Grid.Column="1" Margin="3,0,5,0" Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Center">
<TextBox HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding EmailAddress,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="150" Margin="0, 5"/>
<TextBlock Text="Email address is not valid" Foreground="Red" Visibility="{Binding DataContext.IsEmailAddressInvalidVisible,Mode=OneWay, FallbackValue='Collapsed', RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}"/>
</StackPanel>