2010-10-30 51 views
1

考虑下面的XAML代码片段:Down状态

<ToolBarTray> 
     <ToolBar Band="1" BandIndex="1"> 
      <Button>Go</Button> 
      <Separator></Separator> 
      <Button>Camera 1</Button> 
      <Button>Camera 2</Button> 
      <Button>Camera 3</Button> 
     </ToolBar> 

    </ToolBarTray> 

我如何设置相机1 - 3的方式,当点击其中一个它保持下来(选择)?

回答

1

使用RadioButton s与GroupName相同。如果你想让他们看起来像按钮,从ToggleButton借用风格。

<RadioButton Content="Camera 1" Style="{StaticResource {x:Type ToggleButton}}" GroupName="Camera" /> 
<RadioButton Content="Camera 2" Style="{StaticResource {x:Type ToggleButton}}" GroupName="Camera" /> 
<RadioButton Content="Camera 3" Style="{StaticResource {x:Type ToggleButton}}" GroupName="Camera" />