36 строки
1.8 KiB
XML
36 строки
1.8 KiB
XML
<?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="Xamarin.Forms.Controls.Issues.Github3847"
|
|
xmlns:local="clr-namespace:Xamarin.Forms.Controls.Issues"
|
|
BindingContext="{Binding Source={RelativeSource Self}, Path=Company}">
|
|
|
|
<StackLayout Orientation="Vertical">
|
|
|
|
<Label Text="RelativeSource Self Binding (ContentPage's BindingContext is bound to its own Company property."/>
|
|
<StackLayout Orientation="Horizontal">
|
|
<Label Text="Company Name: "/>
|
|
<Label Text="{Binding Name}"/>
|
|
</StackLayout>
|
|
|
|
<Label Text="RelativeSource AncestorType Binding based on BindingContext Type (Delete Button Command bound to parent's view model's DeleteEmployeeCommand, thus PersonViewModel does not need a reference to its parent, nor is the DataTemplate dependent on the parent View type.)"/>
|
|
<Label Text="Employees:"/>
|
|
<ListView ItemsSource="{Binding Employees}">
|
|
<ListView.ItemTemplate>
|
|
<DataTemplate>
|
|
<ViewCell>
|
|
<StackLayout Orientation="Horizontal">
|
|
<Label Text="{Binding FullName}"/>
|
|
<Button Text="Delete"
|
|
CommandParameter="{Binding}"
|
|
Command="{Binding
|
|
Source={RelativeSource AncestorType={x:Type local:CompanyViewModel}},
|
|
Path=DeleteEmployeeCommand}"/>
|
|
</StackLayout>
|
|
</ViewCell>
|
|
</DataTemplate>
|
|
</ListView.ItemTemplate>
|
|
</ListView>
|
|
</StackLayout>
|
|
</ContentPage>
|