■ Binding 태그 확장의 Path 속성에서 바인딩 경로를 사용하는 방법을 보여준다.
▶ MainPage.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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<?xml version="1.0" encoding="utf-8" ?> <ContentPage x:Class="TestProject.MainPage" x:Name="page" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:globe="clr-namespace:System.Globalization;assembly=netstandard"> <ContentPage.Resources> <Style TargetType="Label"> <Setter Property="FontSize" Value="Large" /> <Setter Property="HorizontalTextAlignment" Value="Center" /> <Setter Property="VerticalOptions" Value="Center" /> </Style> </ContentPage.Resources> <StackLayout Margin="10" HorizontalOptions="Center" VerticalOptions="Center"> <TimePicker x:Name="timePicker" /> <Label Margin="0,10,0,0" Text="{Binding Source={x:Reference timePicker}, Path=Time.TotalSeconds, StringFormat='전체 초 수 : {0}'}" /> <Label Margin="0,10,0,0" Text="{Binding Source={x:Reference page}, Path=Content.Children.Count, StringFormat='StackLayout 자식 수 : {0}'}" /> <Label Margin="0,10,0,0" Text="{Binding Source={x:Static globe:CultureInfo.CurrentCulture}, Path=DateTimeFormat.DayNames[3], StringFormat='주중 요일 : {0}'}" /> <Label Margin="0,10,0,0"> <Label.Text> <Binding Path="DateTimeFormat.DayNames[3]" StringFormat="프랑스에서 주중 요일 : {0}"> <Binding.Source> <globe:CultureInfo> <x:Arguments> <x:String>fr-FR</x:String> </x:Arguments> </globe:CultureInfo> </Binding.Source> </Binding> </Label.Text> </Label> <Label Margin="0,10,0,0" Text="{Binding Source={x:Reference page}, Path=Content.Children[1].Text.Length, StringFormat='두 번째 Label 문자 수 : {0}'}" /> </StackLayout> </ContentPage> |