Classe partielle publique HTCmds: ResourceDictionary { private ICanvasService mCanvasService;Unité: Injection de dépendances
[Dependency]
public ICanvasService CanvasService
{
get { return mCanvasService; }
set { mCanvasService = value; }
}
public HTCmds()
{
CopyCommand = new DelegateCommand<object>(this.Copy, this.CanCopy);
ExitCommand = new DelegateCommand<object>(this.Exit);
}
public DelegateCommand<object> CopyCommand { get; private set; }
public DelegateCommand<object> ExitCommand { get; private set; }
}
ressources Dictionnaire Xaml:
<ResourceDictionary x:Class="HTCmds"
x:ClassModifier="public"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commands="clr-namespace:Commands;assembly=UIInfrastructure"
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:local="clr-namespace:Commands.Commands">
<local:HTCmds x:Key="thisobj"/>
<commands:CommandReference x:Key="CopyCommandReference" Command="{Binding Source={StaticResource thisobj}, Path=CopyCommand}"/>
<commands:CommandReference x:Key="ExitCommandReference" Command="{Binding Source={StaticResource thisobj}, Path=ExitCommand}"/>
</ResourceDictionary>
Je suis donc inscrit le ICanvasService mais il ne s'injecté dans cette classe. Ressource de dictionnaire est fusionné dans le fichier XAML d'une classe de fenêtres:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Commands/HTCmds.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Y at-il quelque chose de spécifique à la classe ResourceDictionary?
Merci & Cordialement, Vishal.
Quelle est votre question? Pourquoi pensez-vous que quelque chose ne va pas? Que devrions-nous rechercher dans le code? – Sjoerd
Je ne parviens pas à obtenir ICanvasService. – Vishal
Où est votre inscription à Unity? Où inscrivez-vous ICanvasService type? – Vadim