using System;
using System.Windows ;
using System.Windows .Input ;
namespace WpfApp1
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
public MainWindow( )
{
InitializeComponent( ) ;
DataContext = new ViewModel( ) ;
}
}
class ViewModel
{
FooModel fooModel = new FooModel( ) ;
public ICommand testbutton { get; set; }
public ViewModel( )
{
testbutton = new TestButtonCommand { model = fooModel } ;
}
}
class TestButtonCommand : ICommand
{
public event EventHandler CanExecuteChanged;
public bool CanExecute( object parameter) => true ; // ←ここをfalseにするとボタン押せないのを確認する
public void Execute( object parameter)
{
model.test ( ) ;
}
public FooModel model { get; set; }
}
class FooModel
{
public void test( )
{
MessageBox.Show ( "Test" ) ;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uV2luZG93czsKdXNpbmcgU3lzdGVtLldpbmRvd3MuSW5wdXQ7CgpuYW1lc3BhY2UgV3BmQXBwMQp7CiAgICAvLy8gPHN1bW1hcnk+CiAgICAvLy8gTWFpbldpbmRvdy54YW1sIOOBruebuOS6kuS9nOeUqOODreOCuOODg+OCrwogICAgLy8vIDwvc3VtbWFyeT4KICAgIHB1YmxpYyBwYXJ0aWFsIGNsYXNzIE1haW5XaW5kb3cgOiBXaW5kb3cKICAgIHsKICAgICAgICBwdWJsaWMgTWFpbldpbmRvdygpCiAgICAgICAgewogICAgICAgICAgICBJbml0aWFsaXplQ29tcG9uZW50KCk7CgogICAgICAgICAgICBEYXRhQ29udGV4dCA9IG5ldyBWaWV3TW9kZWwoKTsKICAgICAgICB9CiAgICB9CgogICAgY2xhc3MgVmlld01vZGVsCiAgICB7CiAgICAgICAgRm9vTW9kZWwgZm9vTW9kZWwgPSBuZXcgRm9vTW9kZWwoKTsKCiAgICAgICAgcHVibGljIElDb21tYW5kIHRlc3RidXR0b24geyBnZXQ7IHNldDsgfQoKICAgICAgICBwdWJsaWMgVmlld01vZGVsKCkKICAgICAgICB7CiAgICAgICAgICAgIHRlc3RidXR0b24gPSBuZXcgVGVzdEJ1dHRvbkNvbW1hbmQgeyBtb2RlbCA9IGZvb01vZGVsIH07CiAgICAgICAgfQogICAgfQoKICAgIGNsYXNzIFRlc3RCdXR0b25Db21tYW5kIDogSUNvbW1hbmQKICAgIHsKICAgICAgICBwdWJsaWMgZXZlbnQgRXZlbnRIYW5kbGVyIENhbkV4ZWN1dGVDaGFuZ2VkOwoKICAgICAgICBwdWJsaWMgYm9vbCBDYW5FeGVjdXRlKG9iamVjdCBwYXJhbWV0ZXIpID0+IHRydWU7IC8vIOKGkOOBk+OBk+OCkmZhbHNl44Gr44GZ44KL44Go44Oc44K/44Oz5oq844Gb44Gq44GE44Gu44KS56K66KqN44GZ44KLCgogICAgICAgIHB1YmxpYyB2b2lkIEV4ZWN1dGUob2JqZWN0IHBhcmFtZXRlcikKICAgICAgICB7CiAgICAgICAgICAgIG1vZGVsLnRlc3QoKTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBGb29Nb2RlbCBtb2RlbCB7IGdldDsgc2V0OyB9CiAgICB9CgogICAgY2xhc3MgRm9vTW9kZWwKICAgIHsKICAgICAgICBwdWJsaWMgdm9pZCB0ZXN0KCkKICAgICAgICB7CiAgICAgICAgICAgIE1lc3NhZ2VCb3guU2hvdygiVGVzdCIpOwogICAgICAgIH0KICAgIH0KfQo=
compilation info
prog.cs(10,39): error CS0246: The type or namespace name `Window' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout