如何在Xaml中创建带有工具提示的RadioButtions绑定列表?
我想创建一个逻辑相关单选按钮列表。单选按钮绑定为MVVM使用。每个单选按钮上都有工具提示。这里有一个样式,它使用列表框创建一组逻辑相关的单选按钮。MyClass包含两个字符串属性:MyName和MyToolTip。该样式将显示单选按钮列表,包括功能正常的单个工具提示。这是一个供MVVM使用的全绑定、全Xaml解决方案 用法示例: ListBox Style=“{StaticResource radioListBox}”ItemsSource=“{Binding MyClass}”SelectedValue=“{Binding SelectedCyclass}”/> 风格:如何在Xaml中创建带有工具提示的RadioButtions绑定列表?,xaml,listbox,radio-button,tooltip,listboxitem,Xaml,Listbox,Radio Button,Tooltip,Listboxitem,我想创建一个逻辑相关单选按钮列表。单选按钮绑定为MVVM使用。每个单选按钮上都有工具提示。这里有一个样式,它使用列表框创建一组逻辑相关的单选按钮。MyClass包含两个字符串属性:MyName和MyToolTip。该样式将显示单选按钮列表,包括功能正常的单个工具提示。这是一个供MVVM使用的全绑定、全Xaml解决方案 用法示例: ListBox Style=“{StaticResource radioListBox}”ItemsSource=“{Binding MyClass}”Selected
<Style x:Key="radioListBox" TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="5" />
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid Background="Transparent">
<RadioButton Focusable="False" IsHitTestVisible="False" IsChecked="{TemplateBinding IsSelected}" Content="{Binding MyName}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ToolTip" Value="{Binding MyToolTip}" />
</Style>
</Setter.Value>
</Setter>
</Style>