-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRelativeSourceDemo.xaml
39 lines (34 loc) · 1.63 KB
/
RelativeSourceDemo.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
36
37
38
39
<!-- =====================================================
RelativeSourceDemo.xaml (c) 2006 by Charles Petzold
===================================================== -->
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
TextBlock.FontSize="12" >
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<TextBlock Text="This TextBlock has a FontFamily of " />
<TextBlock Text="{Binding RelativeSource={RelativeSource self},
Path=FontFamily}" />
<TextBlock Text=" and a FontSize of " />
<TextBlock Text="{Binding RelativeSource={RelativeSource self},
Path=FontSize}" />
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<TextBlock Text="This TextBlock is inside a StackPanel with " />
<TextBlock Text=
"{Binding RelativeSource={RelativeSource
AncestorType={x:Type StackPanel}},
Path=Orientation}" />
<TextBlock Text=" orientation" />
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<TextBlock Text="The parent StackPanel has " />
<TextBlock Text=
"{Binding RelativeSource={RelativeSource
AncestorType={x:Type StackPanel}, AncestorLevel=2},
Path=Orientation}" />
<TextBlock Text=" orientation" />
</StackPanel>
</StackPanel>