回答編集履歴
1
バインドできてなかったので訂正
    
        answer	
    CHANGED
    
    | 
         @@ -9,8 +9,11 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
                    xmlns:local="clr-namespace:WpfApplication2"
         
     | 
| 
       10 
10 
     | 
    
         
             
                    mc:Ignorable="d"
         
     | 
| 
       11 
11 
     | 
    
         
             
                    Title="MainWindow" Height="350" Width="525">
         
     | 
| 
      
 12 
     | 
    
         
            +
                <Window.DataContext>
         
     | 
| 
      
 13 
     | 
    
         
            +
                    <local:MainWindowViewModel />
         
     | 
| 
      
 14 
     | 
    
         
            +
                </Window.DataContext>
         
     | 
| 
       12 
15 
     | 
    
         
             
                <Grid>
         
     | 
| 
       13 
     | 
    
         
            -
                    <local:UserControl1 prop=" 
     | 
| 
      
 16 
     | 
    
         
            +
                    <local:UserControl1 prop="{Binding num}" />
         
     | 
| 
       14 
17 
     | 
    
         
             
                </Grid>
         
     | 
| 
       15 
18 
     | 
    
         
             
            </Window>
         
     | 
| 
       16 
19 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -49,21 +52,26 @@ 
     | 
|
| 
       49 
52 
     | 
    
         
             
            }
         
     | 
| 
       50 
53 
     | 
    
         
             
            ```
         
     | 
| 
       51 
54 
     | 
    
         
             
            ```C#
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
            public class MainWindowViewModel : INotifyPropertyChanged
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 56 
     | 
    
         
            +
            {
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 57 
     | 
    
         
            +
                private int _num;
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                public int num
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
                {
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
                    get
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
                    {
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
                        return _num;
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 63 
     | 
    
         
            +
                    }
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
                    set
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
      
 65 
     | 
    
         
            +
                    {
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
      
 66 
     | 
    
         
            +
                        _num = value;
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
                        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("num"));
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                    }
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 69 
     | 
    
         
            +
                }
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
                public event PropertyChangedEventHandler PropertyChanged;
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                public MainWindowViewModel()
         
     | 
| 
      
 73 
     | 
    
         
            +
                {
         
     | 
| 
      
 74 
     | 
    
         
            +
                    num = 10;
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
      
 75 
     | 
    
         
            +
                }
         
     | 
| 
      
 76 
     | 
    
         
            +
            }
         
     | 
| 
       69 
77 
     | 
    
         
             
            ```
         
     |