Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Xaml中创建带有工具提示的RadioButtions绑定列表?_Xaml_Listbox_Radio Button_Tooltip_Listboxitem - Fatal编程技术网

如何在Xaml中创建带有工具提示的RadioButtions绑定列表?

如何在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

我想创建一个逻辑相关单选按钮列表。单选按钮绑定为MVVM使用。每个单选按钮上都有工具提示。

这里有一个样式,它使用列表框创建一组逻辑相关的单选按钮。MyClass包含两个字符串属性:MyName和MyToolTip。该样式将显示单选按钮列表,包括功能正常的单个工具提示。这是一个供MVVM使用的全绑定、全Xaml解决方案

用法示例:

ListBox Style=“{StaticResource radioListBox}”ItemsSource=“{Binding MyClass}”SelectedValue=“{Binding SelectedCyclass}”/>

风格:

    <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>