WPF 绑定枚举值

原文: WPF 绑定枚举值

前台Xaml      

  <ComboBox x:Name="cmboxStretch"  Width="120" Height="35" HorizontalAlignment="Left" Margin="5 0 0 0"
                             SelectedItem="{Binding Path=Stretch}"
                             VerticalContentAlignment="Center">
            </ComboBox>
  <Viewbox Stretch="{Binding SelectedValue,ElementName=cmboxStretch}" Grid.Row="1" x:Name="viewBox">
  </Viewbox>

后台代码     

 cmboxStretch.ItemsSource= System.Enum.GetValues(typeof(Stretch));

选择Combox就能看到ViewBox属性值Stretch在变化了。

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/9293990.html