Bonjour à tous,
Je bloque sur un problème tout simple mais j'arrive pas à trouver la syntaxe pour binder ma DP avec mon textblock.
Mon tout se trouve au sein d'un même UserControl:
PlayerInformation.xaml :
Dependency Property :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <Canvas x:Name="LayoutRoot" Background="Black"> <TextBlock x:Name="TxtBlPlayerName" Text="{Binding PlayerName}" Foreground="#FF8D7204" FontSize="10.667" Width="225" Height="15" ToolTipService.ToolTip="{Binding PlayerInformationNameDescription, Source={StaticResource Lang}}" /> </Canvas>
Actuellement je le fais au niveau du callback: OnPlayerNameChanged
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 public string PlayerName { get { return (string)GetValue(PlayerNameProperty); } set { SetValue(PlayerNameProperty, value); } } public static readonly DependencyProperty PlayerNameProperty = DependencyProperty.Register("PlayerName", typeof(string), typeof(PlayerInformation), new PropertyMetadata(OnPlayerNameChanged)); ...
J'ai essayé avec Text="{Binding PlayerName}" mais ça ne fonctionne pas, j'ai essayé aussi avec un ElementName=this (sait-on jamais...)
Je dois sans doute zappé quelque chose ?
Merci pour vos lumières.
Cordialement,
Partager