WPF Binding(属性绑定)
WPF Binding
WPF中一个控件绑定另一个控件的属性
参考:
https://www.cnblogs.com/tommy-huang/p/6516093.html
https://www.cnblogs.com/xieyong_198510/p/3437217.html
绑定模板控件
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
绑定ViewModel
<Window x:Class="WpfApplication1.MainWindow" xmlns:vm="clr-namespace:WpfApplication1.ViewModel"> <Window.DataContext> <vm:ShowDataViewModel/> </Window.DataContext> <Grid> <DataGrid ItemsSource="{Binding mylist}"/> </Grid> </Window >