0

アプリケーションを実行しようとすると、次のエラーが発生しました。

'InsightSplash.theMenuConverter' はインターフェイス メンバー 'System.Windows.Data.IValueConverter.Convert(object, System.Type, object, System.Globalization.CultureInfo)' を実装していません

これの何が問題なのですか?私の知る限り、私のインポートは正しいです:

私のXamlインターフェース:

<Window x:Class="InsightSplash.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="clr-namespace:InsightSplash" 
    Title="Window2" Height="300" Width="300" Loaded="Window_Loaded">
<Window.Resources>
    <local:theConverter x:Key="theConverter"/>
    <Style TargetType="{x:Type MenuItem}">
        <Setter Property="IsEnabled" Value="{Binding RelativeSource={RelativeSource Self}, 
            Converter={StaticResource theConverter}}"></Setter>
    </Style>
</Window.Resources>
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" >
    <Menu Grid.Row="0" Width="100" Height="30" IsMainMenu="True">
        <MenuItem x:Name="Menu0" Header="الموارد البشرية" IsEnabled="True" >
            <MenuItem x:Name="Menu1" Header="الادارات الرئيسية"></MenuItem>
            <MenuItem x:Name="Menu2" Header="الموظفين"></MenuItem>
        </MenuItem>
    </Menu>
</Grid>

そして、私の Converter クラスは次のようになります。

public class theMenuConverter : IValueConverter
{
    DataClasses1DataContext dbusers = new DataClasses1DataContext();

    public object convertMe(object value, Type targetType, object parameter, CultureInfo culture)
    {
        MenuItem mi = (MenuItem)value;

        string header = mi.Header.ToString();

        int userID = AFunctionToGetAUser();

        int? permissionID = (from permsion in dbusers.PermissionsTbls
                           where permsion.PermissionDescription == header
                           select permsion.PermissionID).SingleOrDefault();

        bool? pageActivity = (from active in dbusers.ActivePermissionsTbls
                           where active.PermissionID == permissionID && active.UserID == userID
                           select active.PageActive).SingleOrDefault();


        if (pageActivity == true && header != null)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    private int AFunctionToGetAUser()
    {

        return 1;
    }
}

私が持っている私のデータベースは

ActivePermissionsTbl
====================
ActivePermID bigint  
パーミッション ID int
ユーザー ID int
PageActive ビット

権限テーブル
==============
パーミッション ID int
PermissionDescription nvarchar(30)    

4

1 に答える 1

2

問題は、メソッドconvertMeの代わりに名前が付けられていることですConvert(したがって、 が正常に実装されませんIValueConverter)。への変更:

public object Convert(...
于 2013-05-15T21:29:22.877 に答える