728x90
728x170
■ Binding 태그 확장의 Path 속성에서 바인딩 경로를 사용하는 방법을 보여준다.
▶ MainPage.xaml
<?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>
728x90
그리드형(광고전용)
'C# > MAUI' 카테고리의 다른 글
[C#/MAUI/.NET6] Binding 태그 확장 : TargetNullValue 속성을 사용해 NULL 바인딩시 대체 값 설정하기 (0) | 2022.03.11 |
---|---|
[C#/MAUI/.NET6] Binding 태그 확장 : FallbackValue 속성을 사용해 바인딩 오류시 대체 값 설정하기 (0) | 2022.03.11 |
[C#/MAUI/.NET6] RelativeSource 태그 확장 : Mode 속성을 사용해 조상 엘리먼트 참조하기 (0) | 2022.03.11 |
[C#/MAUI/.NET6] Binding 클래스 : ConverterParameter 속성 사용하기 (0) | 2022.03.10 |
[C#/MAUI/.NET6] Binding 태그 확장 : Converter 속성에서 정수↔진리 값 변환자 사용하기 (0) | 2022.03.09 |
[C#/MAUI/.NET6] Binding 태그 확장 : StringFormat 속성에서 포맷 문자열 사용하기 (0) | 2022.03.09 |
[C#/MAUI/.NET6] INotifyPropertyChanged 인터페이스 : HSL 색상 뷰 모델 바인딩하기 (0) | 2022.03.09 |
[C#/MAUI/.NET6] 비주얼 트리에서 바인딩 컨텍스트 상속하기 (0) | 2022.03.08 |
[C#/MAUI/.NET6] Binding 엘리먼트 : Source 속성을 사용해 바인딩 설정하기 (0) | 2022.03.08 |
[C#/MAUI/.NET6] Binding 엘리먼트 : Source/Path 속성을 사용해 바인딩 설정하기 (0) | 2022.03.08 |