0

Clickにあるボタンのイベントをトラップしようとしています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 は次のようになります。

namespace WindowsApplication1
{
  partial class MyResourceDictionary
  {
    public virtual void OnApplyTemplate()
    {
     Button myButton = this.GetTemplateChild("Crap") as Button;
    }
  }
}

MyResourceDictionay.xaml は次のようになります。

<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>

何か助けはありますか?

4

1 に答える 1