Binding du stub de plusieurs players via un datatemplate
continuous-integration/drone/push Build is passing Details

pull/94/head
Remi NEVEU 11 months ago
parent 4733ed0a7e
commit 43877415f9

@ -20,7 +20,7 @@ namespace Stub
{
listplayer.Add(new Player());
listplayer.Add(new Player("Lucas"));
listplayer.Add(new Player("Lucas", "profile.jpg"));
listplayer.Add(new Player("relavergne"));
listplayer.Add(new Player("reneveu"));

@ -1,36 +0,0 @@
namespace Trek_12.Views.Components;
public partial class ContentLeaderBoard : ContentView
{
public ContentLeaderBoard()
{
InitializeComponent();
}
public static readonly BindableProperty Pseudo =
BindableProperty.Create("Pseudo", typeof(string), typeof(ContentLeaderBoard), "");
public string Pseudo
{
get => (string)GetValue(Pseudo);
set => SetValue(Pseudo, value);
}
public static readonly BindableProperty Pseudo =
BindableProperty.Create("Title", typeof(string), typeof(ContentLeaderBoard), "No Title");
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public static readonly BindableProperty SubTitleProperty =
BindableProperty.Create("SubTitle", typeof(string), typeof(ContentLeaderBoard), "Lorem Ipsum Dolor");
public string SubTitle
{
get => (string)GetValue(SubTitleProperty);
set => SetValue(SubTitleProperty, value);
}
}

@ -1,9 +0,0 @@
namespace Trek_12.Views.Components;
public partial class viewsProfils : ContentView
{
public viewsProfils()
{
InitializeComponent();
}
}

@ -1,9 +0,0 @@
namespace Trek_12.Views;
public partial class PageProfils : ContentPage
{
public PageProfils()
{
InitializeComponent();
}
}

@ -69,22 +69,22 @@
</ItemGroup>
<ItemGroup>
<Compile Update="Resources\Views\PageLeaderBoard.xaml.cs">
<Compile Update="Views\PageLeaderBoard.xaml.cs">
<DependentUpon>PageLeaderBoard.xaml</DependentUpon>
</Compile>
<Compile Update="Resources\Views\pageProfils.xaml.cs">
<Compile Update="Views\pageProfils.xaml.cs">
<DependentUpon>PageProfils.xaml</DependentUpon>
</Compile>
<Compile Update="Resources\Views\pageRegles.xaml.cs">
<Compile Update="Views\pageRegles.xaml.cs">
<DependentUpon>PageRegles.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Resources\Views\Components\ContentLeaderBoard.xaml">
<MauiXaml Update="Views\Components\ContentLeaderBoard.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Resources\Views\PageLeaderBoard.xaml">
<MauiXaml Update="Views\PageLeaderBoard.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

@ -0,0 +1,10 @@
namespace Trek_12.Views.Components;
public partial class ContentLeaderBoard : ContentView
{
public ContentLeaderBoard()
{
InitializeComponent();
}
}

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Trek_12.Views.Components.viewsProfils">
x:Class="Trek_12.Views.Components.viewsProfils"
x:Name="this">
<VerticalStackLayout>
<Grid ColumnDefinitions="*,*,*,*" >
<Frame Margin="10"
@ -13,11 +14,11 @@
IsClippedToBounds="True"
HasShadow="True"
HorizontalOptions="CenterAndExpand">
<Image Source="profile.jpg"
<Image Source="{Binding ProfilePicture, Source={x:Reference this}}"
Aspect="AspectFill"
Margin="-20"/>
</Frame>
<Label Text="Profile n°*" Grid.Column="2" TextColor="Black" FontSize="Large" HorizontalTextAlignment="Center" Margin="100"/>
<Label Text="{Binding Pseudo, Source={x:Reference this}}" Grid.Column="2" TextColor="Black" FontSize="Large" HorizontalTextAlignment="Center" Margin="100"/>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -0,0 +1,28 @@
namespace Trek_12.Views.Components;
public partial class viewsProfils : ContentView
{
public viewsProfils()
{
InitializeComponent();
}
public static readonly BindableProperty PseudoProperty =
BindableProperty.Create("Pseudo", typeof(string), typeof(ContentLeaderBoard), "Profile n°*");
public string Pseudo
{
get => (string)GetValue(PseudoProperty);
set => SetValue(PseudoProperty, value);
}
public static readonly BindableProperty ProfilePictureProperty =
BindableProperty.Create("ProfilePicture", typeof(string), typeof(ContentLeaderBoard), "profile.jpg");
public string ProfilePicture
{
get => (string)GetValue(ProfilePictureProperty);
set => SetValue(ProfilePictureProperty, value);
}
}

@ -2,7 +2,6 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Trek_12.Views.Components"
xmlns:player="clr-namespace:Models.Game.Player"
x:Class="Trek_12.Views.PageLeaderBoard"
Title="PageLeaderBoard">
@ -31,16 +30,16 @@
Margin="0,10">
<CollectionView ItemsSource="{Binding ListPlayer}">
<!--<CollectionView ItemsSource="{Binding ListPlayer}">
<CollectionView.ItemTemplate>
<!--<DataTemplate>
--><!--<DataTemplate>
<views:ContentLeaderBoard/>
<Label Text="{Binding Pseudo}"/>
</DataTemplate>-->
</DataTemplate>--><!--
<views:ContentLeaderBoard
/>
</CollectionView.ItemTemplate>
</CollectionView>
</CollectionView>-->
</ScrollView>

@ -6,7 +6,7 @@ public partial class PageLeaderBoard : ContentPage
public Stub MyStub { get; set; } = new Stub();
public PageLeaderBoard()
{
InitializeComponent();
//InitializeComponent();
BindingContext = MyStub;
}
}

@ -14,18 +14,18 @@
<Label Text="Profils" TextColor="black" HorizontalTextAlignment="Center" FontSize="Header" Margin="30"/>
<ScrollView Grid.Row="1">
<Grid RowDefinitions="*,*,*,*,*,*">
<views:viewsProfils />
<views:viewsProfils Grid.Row="1" />
<views:viewsProfils Grid.Row="2"/>
<views:viewsProfils Grid.Row="3"/>
<views:viewsProfils Grid.Row="4"/>
<views:viewsProfils Grid.Row="5"/>
<CollectionView Grid.Row="1" ItemsSource="{Binding ListPlayer}"
ItemsLayout="VerticalList"
VerticalOptions="Center">
<CollectionView.ItemTemplate>
<DataTemplate>
<views:viewsProfils
Pseudo="{Binding Pseudo}"
ProfilePicture="{Binding ProfilePicture}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ScrollView>
<HorizontalStackLayout Grid.Row="2" HorizontalOptions="Center" Spacing="50">
<Button Text="Modifier" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Créer" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>

@ -0,0 +1,13 @@
namespace Trek_12.Views;
using Stub;
public partial class PageProfils : ContentPage
{
public Stub MyStub { get; set; } = new Stub();
public PageProfils()
{
InitializeComponent();
BindingContext = MyStub;
}
}
Loading…
Cancel
Save