WPF Exceed busyindicator + listbox组合样式问题

WPF Exceed busyindicator + listbox combination style issues

我在非常简单的示例中使用了 xceed busyindicator 控件和列表框。所以我将列表框的背景颜色设置为黑色,当 busyindicator 的 isbusy 属性 设置为 true 时。列表框背景颜色变为白色,但其余控件(如网格)背景颜色保持不变。请参见下面的示例。我希望我的列表框颜色与我设置的颜色保持一致,但当 isBusy =true 时它会变为白色。

<Grid Margin="10">
    <xctk:BusyIndicator IsBusy="True">
        <Grid Background="Black">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.50*" />
                <RowDefinition Height="0.50*" />
            </Grid.RowDefinitions>
            <ListBox Background="Black" Foreground="White">
                <ListBoxItem>ListBox Item #1</ListBoxItem>
                <ListBoxItem>ListBox Item #2</ListBoxItem>
                <ListBoxItem>ListBox Item #3</ListBoxItem>
            </ListBox>
        </Grid>

    </xctk:BusyIndicator>
</Grid>

BusyIndi​​cator 默认有一个半透明的 Overlay。此外,它设置基础元素的 IsEnabled=False

你可以这样实现你想要的:

     <Grid Margin="10">
        <Grid.Resources>

            <Style x:Key="_BlackListBoxStyle" TargetType="{x:Type ListBox}">
                <Setter Property="Background" Value="Black" />
                <Setter Property="Foreground" Value="White" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBox}">
                            <Grid Width="Auto" Height="Auto">
                                <Border x:Name="Border" CornerRadius="0,0,0,0" />
                                <ScrollViewer
                                    Focusable="false"
                                    HorizontalScrollBarVisibility="Disabled"
                                    IsTabStop="False"
                                    >
                                    <StackPanel IsItemsHost="true" />
                                </ScrollViewer>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderThickness" Value="0,0,0,0" />
            </Style>
        </Grid.Resources>
        <xctk:BusyIndicator IsBusy="True">
            <Grid Background="Black">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.50*" />
                    <RowDefinition Height="0.50*" />
                </Grid.RowDefinitions>
                <ListBox IsEnabled="False" Style="{StaticResource _BlackListBoxStyle}">
                    <ListBoxItem>ListBox Item #1</ListBoxItem>
                    <ListBoxItem>ListBox Item #2</ListBoxItem>
                    <ListBoxItem>ListBox Item #3</ListBoxItem>
                </ListBox>
            </Grid>
            <xctk:BusyIndicator.OverlayStyle>
                <Style TargetType="Rectangle">
                    <Setter Property="Fill" Value="Transparent" />
                </Style>
            </xctk:BusyIndicator.OverlayStyle>
        </xctk:BusyIndicator>
    </Grid>