WPF 1.Binding

1.第一种绑定方法使用 ElementName + Path

<Button Command="{Binding SubmitCommand}" CommandParameter="{Binding ElementName=textBox1,Path=Text}" Content="提交参数"></Button>

2.第二种绑定方式。 RelativeSource

<Button Content="单击命令带参数" Command="{Binding ClickWithButtonCommand}"  CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}"/>

<ComboBox>
       <i:Interaction.Triggers>
           <i:EventTrigger EventName="SelectionChanged">
               <i:InvokeCommandAction Command="{Binding SelectionComboBoxCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ComboBox}}"/>
           </i:EventTrigger>
       </i:Interaction.Triggers>
       <ComboBoxItem Content="张三"/>
       <ComboBoxItem Content="李四"/>
       <ComboBoxItem Content="王五"/>
</ComboBox>

3.绑定自身

<Grid>  
    <Ellipse Fill="Black" Height="100" Width="{Binding RelativeSource={RelativeSource Self},Path=Height}">  
    </Ellipse>  
</Grid