使用样式设置器将枚举值绑定到属性

时间:2017-10-25 21:23:56

标签: wpf xaml triggers

我有以下代码。请查看单选按钮样式,我想在选中单选按钮时将枚举的值绑定到ViewModel中的属性。我有一个名为SelectedWellType的属性,我想绑定它。但它表示无法在Setter中的Type属性的属性上设置绑定。请帮忙。

<RadioButton
            Name="IndividualWellsRadioButton"
            Grid.Row="0"
            KeyboardNavigation.IsTabStop="True"
            KeyboardNavigation.TabIndex="1"
            KeyboardNavigation.AcceptsReturn="True"
            Content="{StaticResource IndividualWells}"
            IsEnabled="{Binding IsIndividualWellAutoAnalysisPossible}">
            <RadioButton.IsChecked>
                <Binding
                    Converter="{StaticResource enumToBoolConverter}"
                    ConverterParameter="{x:Static dataDef:AutoAnalysisModes.IndividualWells}"
                    Path="AutoAnalysisMode" />
            </RadioButton.IsChecked>
            <RadioButton.Style>
                <Style
                    TargetType="{x:Type RadioButton}">
                    <Style.Triggers>
                        <Trigger
                            Property="IsChecked"
                            Value="True">
                            <Setter
                                Property="{Binding SelectedWellType}"
                                Value="{x:Static dataDef:AutoAnalysisModes.IndividualWells}"></Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </RadioButton.Style>
        </RadioButton>

0 个答案:

没有答案