WPFにおけるmodel属性の即時変更

3670 ワード

説明としてモデルを新規作成して、確認します.
参照を追加:using System.ComponentModel ;  
public class Test:INotifyPropertyChanged 
    {
        private string name;

        public string Name
        {
            get { return this.name; }
            set 
            {
                this.name = value;
                NotifyPropertyChanged("Name");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

 
WPFにwinformコントロールを追加するには:
参照を追加:System.Windows.FormsとWindowsForsIntegration.
xmlns:WinFormHost="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"xmlns:WinForm="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
<WindowsFormsHost Name="wfAll" Height="1002" Width="1652" Background="Black" Canvas.Left="1" >
                            <WinForm:Panel x:Name="panelShowScreen" Dock="Fill" BackColor="Black" >
                            </WinForm:Panel>
                        </WindowsFormsHost>