Problème de binding
Résolu
l.mnu
Messages postés
36
Date d'inscription
Statut
Membre
Dernière intervention
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour,
Quand je mets ce ResourceDictionary dans la même page que l'image, mon binding fonctionne
Quand je mets ce ResourceDictionary dans un fichier xaml en ressource, mon bindind ne fonctionne pas
Dans le fichier de sortie il y a ce message d'erreur :
Quelqu'un aurai une idée pour m'aider
Merci
Quand je mets ce ResourceDictionary dans la même page que l'image, mon binding fonctionne
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <DrawingImage x:Key="MyImage"> <DrawingImage.Drawing> <DrawingGroup> <GeometryDrawing <bold>Brush="{Binding Fond}"</bold> Geometry="M 0,0L 32,0L 32,32L 0,32L 0,0 Z " /> <GeometryDrawing.Pen> <Pen Thickness="1.33333" LineJoin="Round" Brush="#FFFFFFFF"/> </GeometryDrawing.Pen> ....
Quand je mets ce ResourceDictionary dans un fichier xaml en ressource, mon bindind ne fonctionne pas
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:Zoom_svg"> <DrawingImage x:Key="Essai"> <DrawingImage.Drawing> <DrawingGroup> <GeometryDrawing <bold>Brush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type vm:MainWindow}}, Path=DataContext.Fond}"</bold> Geometry="M 0,0L 32,0L 32,32L 0,32L 0,0 Z " /> <GeometryDrawing.Pen> <Pen Thickness="1.33333" LineJoin="Round" Brush="#FFFFFFFF"/> </GeometryDrawing.Pen> ...
Dans le fichier de sortie il y a ce message d'erreur :
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Zoom_svg.MainWindow', AncestorLevel='1''. BindingExpression:Path=DataContext.Fond; DataItem=null; target element is 'GeometryDrawing' (HashCode=53180767); target property is 'Brush' (type 'Brush')
Quelqu'un aurai une idée pour m'aider
Merci
Configuration: Windows / Firefox 65.0
A voir également:
- Binding entities to query parameters only allowed for entities that have an identifier
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Power query download - Télécharger - Tableur
- Qwerty to azerty - Guide
- Comment déverrouiller my eyes only sans code - Forum Snapchat
- I'm sorry to have to inform you that your message could not be delivered to one or more recipients. it's attached below. ✓ - Forum Mail
2 réponses
J'ai trouvé, j'avais mis le code ci-dessous dans le fichier App.xaml et je l'ai déplacé dans les ressources de ma fenêtre ou j'affiche l'image et maintenant le binding fonctionne
J'ai perdu au moins une demi-journée à chercher, grrrrrrrrrr mais je suis contente le résultat est là :-)
<ResourceDictionary x:Name="Fond1">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary x:Name="Essai" Source="Carte_monde.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
J'ai perdu au moins une demi-journée à chercher, grrrrrrrrrr mais je suis contente le résultat est là :-)