Fixed Server Name in Server List

This commit is contained in:
TheJoKlLa 2021-09-25 21:36:22 +02:00
parent f41b69cfd8
commit b2ec0c1a53
3 changed files with 28 additions and 11 deletions

View File

@ -93,7 +93,7 @@ namespace Borepin.PageModel
NavigationParameters parameters = new NavigationParameters NavigationParameters parameters = new NavigationParameters
{ {
{ "instance", viewmodel.Instance } { "instance", viewmodel._Instance }
}; };
INavigationResult result = await _NavigationService.NavigateAsync($"ServerPage", parameters); INavigationResult result = await _NavigationService.NavigateAsync($"ServerPage", parameters);

View File

@ -16,8 +16,8 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="1"/> <RowDefinition Height="1"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Instance.Address, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Primary}"/> <Label Grid.Row="0" Grid.Column="1" Text="{Binding Address, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Primary}"/>
<Label Grid.Row="0" Grid.Column="2" Text="{Binding Instance.Username}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" /> <Label Grid.Row="0" Grid.Column="2" Text="{Binding Username}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" />
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="->" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:ServerListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource Style_Button_Primary}"/> <Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="->" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:ServerListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource Style_Button_Primary}"/>
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/> <BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
</Grid> </Grid>

View File

@ -1,28 +1,45 @@
using Borepin.Model; using Borepin.Model;
using Prism.Mvvm; using Prism.Mvvm;
using System;
namespace Borepin.ViewModel namespace Borepin.ViewModel
{ {
public class ServerListItemViewModel : BindableBase public class ServerListItemViewModel : BindableBase
{ {
#region Private Properties
public Connection _Instance { get; private set; }
#endregion
#region Constructors
public ServerListItemViewModel(Connection instance) public ServerListItemViewModel(Connection instance)
{ {
_Instance = instance; _Instance = instance;
Address = instance.Address.ToString(); Address = ConvertUriToString(instance.Address);
} Username = instance.Username;
private Connection _Instance;
public Connection Instance
{
get => _Instance;
set => SetProperty(ref _Instance, value);
} }
#endregion
#region Properties
private string _Address; private string _Address;
public string Address public string Address
{ {
get => _Address; get => _Address;
set => SetProperty(ref _Address, value); set => SetProperty(ref _Address, value);
} }
private string _Username;
public string Username
{
get => _Username;
set => SetProperty(ref _Username, value);
}
#endregion
#region Methods
public string ConvertUriToString(Uri uri)
{
return uri.Host;
}
#endregion
} }
} }