databinding

master
Cedric CHARBONNEL 2 years ago
parent c42146526d
commit 12836f886e

@ -8,52 +8,43 @@
<model:Manager/>
</ContentPage.BindingContext>
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<ListView x:Name="MAQE" ItemsSource="{Binding _champions}">
<ListView x:Name="champ">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding Name}"/>
<Border Stroke="DarkSalmon" StrokeThickness="4"
Margin="0, 4" Padding="8,4"
BackgroundColor="GhostWhite">
<Border.StrokeShape>
<RoundRectangle CornerRadius="30, 30, 30, 0"/>
</Border.StrokeShape>
<Grid ColumnDefinitions="Auto, *" RowDefinitions="2*, *, *"
ColumnSpacing="15">
<Frame Grid.RowSpan="3"
WidthRequest="60" HeightRequest="60"
Padding="0" CornerRadius="30" Margin="0"
IsClippedToBounds="True"
BorderColor="DarkSalmon" HasShadow="True" >
<Frame.Shadow>
<Shadow Brush="DarkSalmon" Offset="3, 2"
Radius="2" Opacity="0.8"/>
</Frame.Shadow>
</Frame>
<Label Text="{Binding Name}" Grid.Column="1" FontSize="Medium"/>
</Grid>
</Border>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />
<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />
<Label Text="{Binding _champions[1].Name}"/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>

@ -10,17 +10,7 @@ public partial class MainPage : ContentPage
public MainPage()
{
InitializeComponent();
MAQE.BindingContext = Cmanager;
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
BindingContext = Cmanager;
champ.BindingContext = Cmanager._champions;
}
}

@ -11,9 +11,9 @@ namespace LOLAPP.Modele
public class Champion
{
[DataMember]
public string Name { get; set; }
public string Name { get; private set; }
[DataMember]
public List<Ability> Abilities { get; set; }
public List<Ability> Abilities { get; private set; }
public Champion(string name, List<Ability> abilities)
{

@ -17,7 +17,9 @@ namespace LOLAPP.Modele
Ability a1 = new Ability("Broken Wings");
a.Add(a1);
Champion c1 = new Champion("Riven", a);
Champion c2 = new Champion("Braum");
c.Add(c1);
c.Add(c2);
Utilisateur s1 = new Utilisateur("Broken", "Kala");
s.Add(s1);
return (s,c);

Loading…
Cancel
Save