j'ai créé un UserControl WPF:Accès objet XAML à partir du code
En XAML:
<UserControl x:Class="OutlookPanel.MailRelation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300"
xmlns:graph="clr-namespace:MyPanel"
>
<DockPanel>
<graph:Graph Name="theGraph" NodesBindingPath="ChildNodes"
NodeTemplateSelector="{StaticResource nodeTemplateSelector}">
..
</DockPanel>
</UserControl>
I cs:
object theThing = e.Parameter;
((MailRelation)sender).theGraph.CenterObject = theThing;
Cette dernière phrase ne fonctionne pas comme theGraph est pas accessible . Une idée de pourquoi je peux accéder au graphique?
Merci
John
Wow, c'est vrai ... Pouvez-vous expliquer la différence? – user96547
Dépend de ce que Graph est. Quelle classe s'étend-elle? –
si l'objet avec lequel vous travaillez ne contient pas déjà un champ Nom, vous pouvez utiliser x: Name, qui est une propriété étendue. –