0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio / WPF > IDE > Error: 'Greeting'はインターフェイスメンバー 'INotifyPropertyChange.ProPertyChanged'を実装しません。> マウスクリックでの対処

Last updated at Posted at 2017-06-05
動作環境
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

http://gushwell.ldblog.jp/archives/52301656.html
を参考に学習中。

エラー

code

MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
//
using System.ComponentModel;

namespace _170605_t1120_singleBinding
{
    /// <summary>
    /// MainWindow.xaml の相互作用ロジック
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }

    public class Greeing : INotifyPropertyChanged
    {
        private bool _isFriendly;
        public bool IsFriendly
        {
            get { return _isFriendly; }
            set {
                if (value != this._isFriendly)
                {
                    this._isFriendly = value;
                    NotifyPropertyChanged("IsFriendly");
                }
            }
        }

        public event PropertyChangedEventHandler hndlr;

        private void NotifyPropertyChanged(string info)
        {
            if (hndlr != null)
            {
                hndlr(this, new PropertyChangedEventArgs(info));
            }
        }
        public void Greet()
        {
            NotifyPropertyChanged("Message");
        }
    }
}

エラーメッセージ

'Greeting'はインターフェイスメンバー 'INotifyPropertyChange.ProPertyChanged'を実装しません。

対処

赤波線のところにマウスカーソルを持っていく。

2017-06-05_11h28_40.png

考えられる修正内容を表示する (Alt+EnterまたはCtrl*.)

という記載をクリックしてみると以下が表示される。

2017-06-05_11h30_28.png

次に「インターフェイスを実装します。」を選択すると以下の行が追加された。

        public event PropertyChangedEventHandler PropertyChanged;

PropertyChangedという名前でなく、自分で勝手に決めたhndlrという命名が間違いだった。

間違い
        public event PropertyChangedEventHandler hndlr;

IDEのこの便利な機能はどこまで使っていいものかは要検討。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?