-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Github3847.xaml
35 lines (32 loc) · 1.82 KB
/
Github3847.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?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>