Added: ListView Template

This commit is contained in:
TheJoKlLa 2021-01-25 22:48:41 +01:00
parent 9347a6160f
commit 1209796099
18 changed files with 224 additions and 37 deletions

View File

@ -5,6 +5,8 @@ using Borepin.Page;
using Xamarin.Forms;
using Borepin.Service;
using Borepin.Service.ServerInstances;
using Borepin.View;
using Borepin.ViewModel;
namespace Borepin
{
@ -19,7 +21,8 @@ namespace Borepin
{
InitializeComponent();
var result = await NavigationService.NavigateAsync("/NavigationPage/HostSelectPage");
//var result = await NavigationService.NavigateAsync("/NavigationPage/HostSelectPage");
var result = await NavigationService.NavigateAsync("/ListPage");
if (!result.Success)
{
@ -37,7 +40,10 @@ namespace Borepin
containerRegistry.RegisterForNavigation<LoginPasswordPage, LoginPasswordPageModel>();
containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>();
containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>();
containerRegistry.RegisterForNavigation<ServerInstancesPage, ServerInstancesPageModel>();
containerRegistry.RegisterForNavigation<BFFHInstancesPage, BFFHInstancesPageModel>();
containerRegistry.RegisterForNavigation<ListPage, ListPageModel>();
BFFHInstanceService bffhInstanceService = new BFFHInstanceService();

View File

@ -31,6 +31,9 @@
<Compile Update="Page\MachinesPage.xaml.cs">
<DependentUpon>MachinesPage.xaml</DependentUpon>
</Compile>
<Compile Update="Page\BFFHInstancesPage.xaml.cs">
<DependentUpon>BFFHInstancesPage.xaml</DependentUpon>
</Compile>
<Compile Update="Page\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
@ -47,11 +50,17 @@
<Compile Update="Styles\LightTheme.xaml.cs">
<DependentUpon>LightTheme.xaml</DependentUpon>
</Compile>
<Compile Update="View\BFFHInstanceEntryView.xaml.cs">
<DependentUpon>BFFHInstanceEntryView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Page\HostSelectPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\ListPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\LoginChoosePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
@ -67,7 +76,7 @@
<EmbeddedResource Update="Page\MainPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\ServerInstancesPage.xaml">
<EmbeddedResource Update="Page\BFFHInstancesPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\SettingsPage.xaml">
@ -84,7 +93,10 @@
<EmbeddedResource Update="Styles\LightTheme.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="View\HostView.xaml">
<EmbeddedResource Update="View\BFFHInstanceEntryView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="View\ListItemView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>

View File

@ -0,0 +1,7 @@
namespace Borepin.Model
{
public class ListItem
{
public string Value1 { get; set; }
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.BFFHInstancesPage">
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding ServerInstance_List}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:BFFHInstanceEntryView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -10,9 +10,9 @@ using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ServerInstancesPage : ContentPage
public partial class BFFHInstancesPage : ContentPage
{
public ServerInstancesPage()
public BFFHInstancesPage()
{
InitializeComponent();
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.ListPage">
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding ListItemViewModel_List}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:ListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ListPage : ContentPage
{
public ListPage()
{
InitializeComponent();
}
}
}

View File

@ -9,7 +9,7 @@
<StackLayout>
<Button Text="Machines" Command="{Binding NavigateCommand}" CommandParameter="MachinesPage" />
<Button Text="Settings" Command="{Binding NavigateCommand}" CommandParameter="SettingsPage" />
<Button Text="Servers" Command="{Binding NavigateCommand}" CommandParameter="ServerInstancesPage" />
<Button Text="Servers" Command="{Binding NavigateCommand}" CommandParameter="BFFHInstancesPage" />
</StackLayout>
</ContentPage>
</MasterDetailPage.Master>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.ServerInstancesPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -7,12 +7,12 @@ using System.Threading.Tasks;
namespace Borepin.PageModel
{
public class ServerInstancesPageModel : BindableBase
public class BFFHInstancesPageModel : BindableBase
{
private INavigationService _NavigationService;
private IBFFHInstanceService _BFFHInstanceService;
public ServerInstancesPageModel(INavigationService navigationService, IBFFHInstanceService bffhInstanceService)
public BFFHInstancesPageModel(INavigationService navigationService, IBFFHInstanceService bffhInstanceService)
{
_NavigationService = navigationService;
_BFFHInstanceService = bffhInstanceService;

View File

@ -0,0 +1,57 @@
using Borepin.Model;
using Borepin.ViewModel;
using Prism.Mvvm;
using System.Collections.Generic;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class ListPageModel : BindableBase
{
public ListPageModel()
{
ListItemViewModel_List = new List<ListItemViewModel>()
{
new ListItemViewModel(
new ListItem()
{
Value1 = "ListItem 1"
}),
new ListItemViewModel(
new ListItem()
{
Value1 = "ListItem 2"
}),
new ListItemViewModel(
new ListItem()
{
Value1 = "ListItem 3"
}),
};
SelectListItemCommand = new Command<object>(SelectListItemCommandExecuted);
}
private List<ListItemViewModel> _ListItemViewModel_List;
public List<ListItemViewModel> ListItemViewModel_List
{
get => _ListItemViewModel_List;
set => SetProperty(ref _ListItemViewModel_List, value);
}
private ICommand _SelectListItemCommand;
public ICommand SelectListItemCommand
{
get => _SelectListItemCommand;
set => SetProperty(ref _SelectListItemCommand, value);
}
private void SelectListItemCommandExecuted(object obj)
{
System.Diagnostics.Debugger.Break();
}
}
}

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.View.HostView">
x:Class="Borepin.View.BFFHInstanceEntryView">
<ContentView.Content>
<StackLayout>
<Label Text="Hello Xamarin.Forms!" />
<Label Text="{Binding Address}" />
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.View
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class BFFHInstanceEntryView : ContentView
{
public BFFHInstanceEntryView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.View.ListItemView"
xmlns:pagemodel="clr-namespace:Borepin.PageModel">
<ContentView.Content>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="{Binding Value}" />
<Button Text="X" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:ListPageModel}}, Path=SelectListItemCommand}" CommandParameter="{Binding .}" />
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -10,9 +10,9 @@ using Xamarin.Forms.Xaml;
namespace Borepin.View
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class HostView : ContentView
public partial class ListItemView : ContentView
{
public HostView()
public ListItemView()
{
InitializeComponent();
}

View File

@ -0,0 +1,20 @@
using Borepin.Model;
using Prism.Mvvm;
namespace Borepin.ViewModel
{
public class BFFHInstanceEntryViewModel : BindableBase
{
private string _Address;
public string Address
{
get => _Address;
set => SetProperty(ref _Address, value);
}
public BFFHInstanceEntryViewModel(BFFHInstance bffhInstance)
{
Address = bffhInstance.Address.ToString();
}
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
namespace Borepin.ViewModel
{
public class HostViewModel : BindableObject
{
}
}

View File

@ -0,0 +1,20 @@
using Borepin.Model;
using Prism.Mvvm;
namespace Borepin.ViewModel
{
public class ListItemViewModel : BindableBase
{
public ListItemViewModel(ListItem listItem)
{
Value = listItem.Value1;
}
private string _Value;
public string Value
{
get => _Value;
set => SetProperty(ref _Value, value);
}
}
}