Je suis en train de piéger l'événement Click
un bouton qui est dans un ResourceDictionary
mais je reçois une erreur:piège l'événement de clic pour un bouton qui est dans le ResourceDictionary
'WpfApplication1.MyResourceDictionary' does not contain a definition for 'GetTemplateChild' and no extension method 'GetTemplateChild' accepting a first argument of type 'WpfApplication1.MyResourceDictionary' could be found (are you missing a using directive or an assembly reference?)
MyResourceDictionay.xaml. cs ressemble à ceci:
namespace WindowsApplication1
{
partial class MyResourceDictionary
{
public virtual void OnApplyTemplate()
{
Button myButton = this.GetTemplateChild("Crap") as Button;
}
}
}
MyResourceDictionay.xaml ressemble à ceci:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WindowsApplication1.MyResourceDictionary"
x:ClassModifier="public">
<ControlTemplate x:Key="ExpandablePropertyEditorTemplate">
<Button x:Name="Crap" Foreground="White" Background="White">
<Image Source="Controls\check.png"/>
</Button>
</ControlTemplate>
</ResourceDictionary>
Toute aide?