HI,propriété UserControl de base Reliure
J'ai un UserControl Silverlight où je lie la UserControl.Background propriété à un élément de frontière à l'intérieur. J'ai trouvé un moyen facile de lier l'arrière-plan comme ça:
<UserControl x:Name="root"
x:Class="TestProject.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="Red" >
<Border x:Name="brdMain" Background="{Binding Path=Background, ElementName=root }" >
etc... .... ...
</Border>
Le problème avec c'est quand j'instancier mes UserControl plusieurs fois. Je reçois l'erreur suivante:
Error: Unhandled Error in Silverlight Application
Code: 2028
Category: ParserError
Message: The name already exists in the tree: root.
File:
Line: 0
Position: 0
Alors est-il une autre meilleure façon de lier ma propriété de fond Usercontrol sans avoir à nommer mon UserControl comme ça: x: Name = « root »?
Merci
ne fonctionne pas ... obtenir l'erreur suivante: la propriété « AncestorType » n'a pas été trouvé dans le type RelativeSource – danbord
@danbord Arg ... SL n » t soutenir FindAncestor; laissez-moi voir s'il y a une autre façon –
@danbord Ajout de détails supplémentaires ... –