Fixed bug in LoginView
fixed never appering erorr message in login form
This commit is contained in:
parent
ab827d849c
commit
7bbae1b17c
@ -9,6 +9,7 @@
|
||||
<local:BootStrapper x:Key="Bootstrapper" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
@ -40,6 +40,35 @@ namespace RMWPFUserInterface.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsErrorVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
bool output = false;
|
||||
|
||||
if (ErrorMessage?.Length > 0)
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
private string _errorMessage;
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _errorMessage; }
|
||||
set
|
||||
{
|
||||
_errorMessage = value;
|
||||
NotifyOfPropertyChange(() => IsErrorVisible);
|
||||
NotifyOfPropertyChange(() => ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool CanLogIn
|
||||
{
|
||||
get{
|
||||
@ -60,11 +89,12 @@ namespace RMWPFUserInterface.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
ErrorMessage = "";
|
||||
var result = await _apiHelper.Authenticate(UserName, Password);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
ErrorMessage = ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="0 0 0 20"
|
||||
@ -25,20 +26,27 @@
|
||||
Login Form
|
||||
</TextBlock>
|
||||
|
||||
<!-- Error Message Row-->
|
||||
<TextBlock x:Name="ErrorMessage" Visibility="{Binding IsErrorVisible, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}"
|
||||
Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Margin="0 0 0 20"
|
||||
MaxWidth="300"
|
||||
TextWrapping="Wrap" Foreground="Red"/>
|
||||
|
||||
<!-- Username row -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0 0 10 20">
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Margin="0 0 10 20">
|
||||
Username:
|
||||
</TextBlock>
|
||||
<TextBox x:Name="UserName" Grid.Row="1" Grid.Column="2" MinWidth="200" Margin="0 0 0 10"/>
|
||||
<TextBox x:Name="UserName" Grid.Row="2" Grid.Column="2" MinWidth="350" Margin="0 0 0 10"/>
|
||||
|
||||
<!-- Password row -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Margin="0 0 10 20">
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Margin="0 0 10 20">
|
||||
Password:
|
||||
</TextBlock>
|
||||
<PasswordBox x:Name="Password" Grid.Row="2" Grid.Column="2" MinWidth="200" Margin="0 0 0 10"/>
|
||||
<PasswordBox x:Name="Password" Grid.Row="3" Grid.Column="2" MinWidth="350" Margin="0 0 0 10"/>
|
||||
|
||||
<!-- Login button -->
|
||||
<Button Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Padding="20 5"
|
||||
<Button Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Padding="20 5"
|
||||
HorizontalAlignment="Center" x:Name="LogIn">
|
||||
Log in
|
||||
</Button>
|
||||
|
Loading…
Reference in New Issue
Block a user