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" />
|
<local:BootStrapper x:Key="Bootstrapper" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</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
|
public bool CanLogIn
|
||||||
{
|
{
|
||||||
get{
|
get{
|
||||||
@ -60,11 +89,12 @@ namespace RMWPFUserInterface.ViewModels
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ErrorMessage = "";
|
||||||
var result = await _apiHelper.Authenticate(UserName, Password);
|
var result = await _apiHelper.Authenticate(UserName, Password);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="0 0 0 20"
|
<TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="0 0 0 20"
|
||||||
@ -25,20 +26,27 @@
|
|||||||
Login Form
|
Login Form
|
||||||
</TextBlock>
|
</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 -->
|
<!-- 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:
|
Username:
|
||||||
</TextBlock>
|
</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 -->
|
<!-- 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:
|
Password:
|
||||||
</TextBlock>
|
</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 -->
|
<!-- 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">
|
HorizontalAlignment="Center" x:Name="LogIn">
|
||||||
Log in
|
Log in
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user