2016-08-24 1 views
1

申し訳ありませんが、私のプロジェクトはClassLibraryとしてビルドされていますが、私がCoreAuthKeyTestButtonをクリックすると、 .SettingsWindowクラス。 CoreAuthKeyTestButton_Click関数はVisual Studioによって自動的に生成されたものであり、動作していることを出力するコード行を投げただけです。WPF MetroWindow Buttonクリックするとコンパイルエラーが表示されます。 "定義には含まれていません..."

私が作っているプログラムは別のアプリケーションのプラグインですが、それは問題ではありませんが、それを指摘したいと思います。

Visual Studioでは、このコードは問題ありません。私はそれを構築するときにエラーはありません。私はプラグインを読み込むときしかし、私はこのエラーを取得する:

using System; 
using System.Linq; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Threading; 
using MahApps.Metro; 
using MahApps.Metro.Controls; 
using Buddy.Overlay.Commands; 
using System.Windows.Input; 
using ff14bot.Helpers; 

namespace ExternalChat 
{ 
    public partial class SettingsWindow 
    { 
     public static string CoreAuthKey { get; set; } 
     public static string CoreAuthKeyTest { get; set; } 

     public SettingsWindow() 
     { 
      InitializeComponent(); 
     } 

     protected void CoreAuthKeyTestButton_Click(object sender, RoutedEventArgs e) 
     { 
      Logging.Write("Save Core Auth Key Button Click Called"); 
     } 
    } 
} 

すべてのヘルプ:

SettingsWindow.xaml(41,92) : error CS1061: 'SettingsWindow' does not contain a definition for 'CoreAuthKeyTestButton_Click' and no extension method 'CoreAuthKeyTestButton_Click' accepting a first argument of type 'SettingsWindow' could be found (are you missing a using directive or an assembly reference?) 

これはこれはSettingsWindow.xaml.csファイルですSettingsWindow.xaml

<Controls:MetroWindow 
x:Class="ExternalChat.SettingsWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
Title="ExternalChat Settings" 
Height="300" 
Width="800" 
GlowBrush="{DynamicResource AccentColorBrush}" 
WindowStartupLocation="CenterScreen"> 

    <Window.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! --> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> 
       <!-- Accent and AppTheme setting --> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> 
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </Window.Resources> 

    <Grid Background="#FF2B2B2B"> 
     <Grid.Resources> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" /> 
     </Grid.Resources> 
     <TabControl> 
      <TabItem Header="Home" IsSelected="True"> 
       <Grid Height="218" VerticalAlignment="Top" Margin="21,0,13,0"> 
        <TextBlock x:Name="HomeTextBlock" HorizontalAlignment="Left" TextWrapping="Wrap" Text="Boy, it sure is unfortunate I still haven't been properly named. What kind of name is ExternalChat? I should have some fancy name based off of FFXIV lore. If only someone would name me..." VerticalAlignment="Top"/> 
       </Grid> 
      </TabItem> 
      <TabItem Header="Keys"> 
       <Grid HorizontalAlignment="Left" Height="218" VerticalAlignment="Top" Width="760" Margin="15,0,0,0"> 
        <Label x:Name="CoreAuthKeyLabel" Content="Core Auth Key:" HorizontalAlignment="Left" VerticalAlignment="Top"/> 
        <TextBox x:Name="CoreAuthKeyInput" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="400" Margin="93,1,0,0" Text="{Binding Path=CoreAuthKey}"/> 
        <Button x:Name="CoreAuthKeyTestButton" Content="Save &amp; Test Key" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Margin="492,1,0,0" BorderThickness="1" Height="26" Click="CoreAuthKeyTestButton_Click" /> 
        <TextBlock x:Name="CoreAuthKeyTestResult" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Margin="597,5,0,0" Width="150" Text="{Binding Path=CoreAuthKeyTest}"/> 
       </Grid> 
      </TabItem> 
     </TabControl> 
    </Grid> 
</Controls:MetroWindow> 

です私が間違ってやっていることを理解することができません、私はそれが私のxamlファイル内の何かの問題だと仮定しますが、私はそれが何であるかを知ることができません。

答えて

0

になります!

このトピックでは、それを説明する:https://stackoverflow.com/a/25110084/5377206私の特定のインスタンスで

私は

<Button Name="CoreAuthKeyTestButton" Content="Save &amp; Test Key" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Margin="492,1,0,0" BorderThickness="1" Height="26" /> 

にボタンを変更し、に自分のSettingsWindow.xaml.csを変更:このことができます

public SettingsWindow() 
    { 
     InitializeComponent(); 
     CoreAuthKeyTestButton.Click += (s, e) => { CoreAuthKeyTestButtonClickAction(); }; 
    } 

    private void CoreAuthKeyTestButtonClickAction() 
    { 
     Logging.Write("Save Core Auth Key Button Click Called"); 
    } 

・ホープ誰かが問題を抱えている場合は誰か。

0
using MahApps.Metro.Controls; 
// 
public partial class MainWindow : MetroWindow 

あなたは、私は解決策を見つけた

public partial class SettingsWindow : MetroWindow 
+0

パブリック部分クラスSettingsWindow:MetroWindowに変更しても、それと同じエラーです。 – AnExiledGod

関連する問題