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在变化了。

posted @ 2016-07-07 22:39  ligl007  阅读(2594)  评论(0编辑  收藏  举报