Привязка к родительскому элементу Xamarin
У меня есть юзер контрол:
<ContentView.Content>
<StackLayout>
<Frame x:Name="PasswordFrame" Padding="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Entry Grid.Row="0"
x:Name="Password"
Text="Password"
IsPassword="True"
Placeholder="Password"/>
<Label Grid.Row="1"
x:Name="PasswordErrorLabel"
TextColor="{DynamicResource ErrorColor}"
Padding="2" />
</Grid>
</Frame>
</StackLayout>
</ContentView.Content>
Так же есть свойство в самом контроле:
public string PasswordText {
get => (string) GetValue(PasswordTextProperty);
set => SetValue(PasswordTextProperty, value);
}
Как я могу привязать свойство 'Text' в Entry:
Text="Password" к свойству самого контрола? Как-то так:
Text = "{Binding PasswordText}"
Ответы (1 шт):
Автор решения: veksela
→ Ссылка
Проблему решил!
Text="{Binding Source={RelativeSource AncestorType={x:Type controls:PasswordEntry},
AncestorLevel=1}, Path=PasswordText}"