簡體   English   中英

為什么單選按鈕沒有出現在Windows 8的彈出窗口中?

[英]Why do radio buttons not appear in Windows 8 on a popup?

我已經使用VS2010在Windows 7上開發了WPF / C#/。NET 4.0應用程序。 該應用程序可以很好地運行,並且可以在XP和Windows 7上正常運行。但是,在具有最新更新的Windows 8上,單選按鈕(默認選擇的按鈕除外)不會顯示在彈出窗口中,盡管有空格。 如果將鼠標移到單選按鈕應位於的位置,則當鼠標懸停在單選按鈕上時,該按鈕將按原樣顯示。 然后,將鼠標從其上方移開時,該按鈕將按原樣顯示,而當鼠標不在其上方時,該按鈕應以開始但沒有的方式顯示。

在我有單選按鈕的所有其他情況下,它們都按應有的方式工作,除了它們沒有按應有的對齊方式。 它們在XP和Windows 7中正確對齊。

更正:我使用.NET 3.5開發了它,最近又更改為.NET 4.0平台。 在.NET 3.5平台上編譯並在Windows 8上運行時,這些單選按鈕將按應有的方式顯示。 除了切換到.NET 4.0平台並進行編譯,然后在Windows 8下運行外,無需進行其他任何更改,單選按鈕不再顯示應有的樣子,而是將鼠標移到它們上方時應有的樣子。

第一次顯示彈出窗口時,如何使那些單選按鈕顯示在非鼠標懸停狀態?

這是彈出的XAML,所有其他控件在Windows 8中都可以正常顯示和運行,例如CheckBoxes:

<Popup Name="MainPrintMenu"
        PlacementTarget="{Binding ElementName=btnPrint}"
        Placement="Bottom"
        HorizontalOffset="-99"
        VerticalOffset="-5"
        AllowsTransparency="True"
        StaysOpen="False">
    <Border BorderThickness="2"
            Background="White"
            CornerRadius="5"
            BorderBrush="Black">
        <Grid Background="Transparent">
            <StackPanel Name="PrintButtons"
                        Orientation="Vertical"
                        Background="Transparent"
                        Margin="5"
                        >
                <StackPanel.Resources>
                    <Style TargetType="Button">
                        <Setter Property="FontSize" Value="12" />
                        <Setter Property="FontWeight" Value="Bold" />
                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                        <Setter Property="BorderBrush" Value="{x:Null}" />
                    </Style>
                    <Style TargetType="RadioButton">
                        <Setter Property="FontSize" Value="10" />
                        <Setter Property="FontWeight" Value="Bold" />
                        <Setter Property="HorizontalContentAlignment" Value="Left" />
                        <Setter Property="BorderBrush" Value="{x:Null}" />
                        <Style.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value="0.50" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                    <Style TargetType="CheckBox">
                        <Setter Property="FontSize" Value="10" />
                        <Setter Property="HorizontalContentAlignment" Value="Left" />
                        <Setter Property="Margin" Value="18,0,0,10" />
                        <Setter Property="BorderBrush" Value="{x:Null}" />
                        <Style.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value="0.50" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Resources>

                <RadioButton Name="MainPrintMenu_PQAI" GroupName="PM" Content="Print My 911 Info" IsChecked="True" />
                <StackPanel Orientation="Vertical" IsEnabled="{Binding ElementName=MainPrintMenu_PQAI, Path=IsChecked}" Margin="18,0,0,0">
                    <RadioButton Name="MainPrintMenu_PQAIR" GroupName="PM_PQAI" Content="Report" IsChecked="True" />
                    <CheckBox Name="PQAI_Blank" Content="Print blank entries too" IsEnabled="{Binding ElementName=MainPrintMenu_PQAIR, Path=IsChecked}" Margin="18,0,0,0" />
                    <RadioButton Name="MainPrintMenu_PQAIW" GroupName="PM_PQAI" Content="Wallet Card" Margin="0,0,0,10" />
                </StackPanel>

                <StackPanel Name="PrintIfLoggedIn" Orientation="Vertical">
                    <RadioButton Name="MainPrintMenu_PAF" GroupName="PM" Content="Print All Folders"/>
                    <CheckBox Name="PAF_Blank" Content="Print blank entries too" IsEnabled="{Binding ElementName=MainPrintMenu_PAF, Path=IsChecked}" />
                    <RadioButton Name="MainPrintMenu_PCF" GroupName="PM" Content="Print Current Folder: Folder" />
                    <CheckBox Name="PCF_Blank" Content="Print blank entries too" IsEnabled="{Binding ElementName=MainPrintMenu_PCF, Path=IsChecked}" />
                    <RadioButton Name="MainPrintMenu_PCSF" GroupName="PM" Content="Print Current Sub-Folder: :[Sub-FolderName]:" />
                    <CheckBox Name="PCSF_Blank" Content="Print blank entries too" IsEnabled="{Binding ElementName=MainPrintMenu_PCSF, Path=IsChecked}" />
                    <RadioButton Name="MainPrintMenu_PCForm" GroupName="PM" Content="Print Current Form: :[From]:" />
                    <CheckBox Name="PCForm_Blank" Content="Print blank entries too" IsEnabled="{Binding ElementName=MainPrintMenu_PCForm, Path=IsChecked}" />
                    <RadioButton Name="MainPrintMenu_PQRC" GroupName="PM" Content="Print QR Code" />
                    <StackPanel Margin="18,0,0,0"  Orientation="Horizontal" >
                        <Image Source="/LR;Component/Image/LR_QR.jpg" Width="30" Height="30" Margin="0,2,5,0" VerticalAlignment="Top" />
                        <TextBlock Width="250" Height="86" FontSize="8" TextWrapping="Wrap" IsEnabled="{Binding ElementName=MainPrintMenu_PQRC, Path=IsChecked}" >
                            A QR code is a small graphic image that can be quickly scanned by smartphone and
                            other devices.<LineBreak/><LineBreak/>
                            The QR code will contain only the emergency information you entered into the Quick
                            Assist folder.<LineBreak/><LineBreak/>
                            Print the QR code and affix it to the back of your LR USB card (or elsewhere).
                            In an emergency it can be scanned and your important information available immediately
                            (no need to start LR)
                        </TextBlock>
                    </StackPanel>
                </StackPanel>

                <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                    <Button Content="Print" Width="233" Click="Event_MainPrintMenu_Print_Click" IsEnabled="{Binding BindingGroupName=MPM, Path=Selected}"/>
                    <Button Content="Cancel" Width="70" Click="Event_MainPrintMenu_Cancel_Click" />
                </StackPanel>

            </StackPanel>
        </Grid>
    </Border>
</Popup>

事實證明這很容易解決。 這是上述問題的XAML部分已更改:

<Style TargetType="RadioButton">
    <Setter Property="FontSize" Value="10" />
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="BorderBrush" Value="{x:Null}" />
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Opacity" Value="0.50" />
        </Trigger>
    </Style.Triggers>
</Style>

需要做的就是從上述XAML中刪除以下行:

<Setter Property="BorderBrush" Value="{x:Null}" />

用於設置RadioButton樣式的XAML來自此處的另一篇文章,但是Values更改為我需要的內容。 我已經離開了BorderBrush值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM