2

我使用 a ProgressBar,但是当我更改其主题时,它看起来会有所不同。

我将windows主题从个性化选项(即右键单击桌面)更改为windows经典主题(即基本和高对比度主题),如下所示:

<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"
            Background="Transparent">
    <ProgressBar IsIndeterminate="True" Height="20" Width="300"
                 VerticalAlignment="Center" BorderThickness="0"
                 BorderBrush="Transparent" HorizontalAlignment="Center"
                 Foreground="#0A8098" >
        <ProgressBar.Background>
            <ImageBrush ImageSource="/ClientApplication;component/Images/ProgressBackground.png"/>
        </ProgressBar.Background>
        <ProgressBar.Clip>
            <RectangleGeometry RadiusX="20.5" RadiusY="20.5" Rect="0,0,300,19"/>
        </ProgressBar.Clip>
    </ProgressBar>

    <TextBlock Text="LOADING PLEASE WAIT" Margin="0 10 0 0" VerticalAlignment="Center"
               HorizontalAlignment="Center" Foreground="#FFFFFF" />
</StackPanel>

和图像:

经典主题

然后我再次将 windows 经典主题更改为 windows 7(即 aero 主题),

航空主题

但我想要第一个但不影响/改变主题。

知道该怎么做吗?谢谢。

4

1 回答 1

1

The ProgressBar is dependent on Windows Themes. You could just create your own progress bar and show/hide it when you want.

The only drawback is that you need to manually write some logic if you want it to be tied to a progress percentage.

With WPF, you can draw out your own progress bar and animate it as you like.

<Rectangle Name="LoadingRectangle" Stroke="Black" Fill="#C0000000" Visibility="{Binding Path=LoadingIcon}" />
<Canvas Name="LoadingIcon" RenderTransformOrigin="0.5,0.5" Width="120" Height="120" Visibility="{Binding Path=LoadingIcon}" >     

<Ellipse Width="19.5" Height="19.5" Canvas.Left="20.1696" Canvas.Top="9.76358" Stretch="Fill" Fill="DarkGoldenrod"/>        
<Ellipse Width="18" Height="18" Canvas.Left="2.86816" Canvas.Top="29.9581" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#E9000000" />        
<Ellipse Width="17" Height="17" Canvas.Left="5.03758e-006" Canvas.Top="57.9341" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#E1000000" />         
<Ellipse Width="16" Height="16" Canvas.Left="12" Canvas.Top="85" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#D2000000" />         
<Ellipse Width="15" Height="15" Canvas.Left="37" Canvas.Top="102" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#BC000000" />         
<Ellipse Width="14" Height="14" Canvas.Left="66" Canvas.Top="101" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#9C000000" />         
<Ellipse Width="13" Height="13" Canvas.Left="91" Canvas.Top="86" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#7B000000" />         
<Ellipse Width="11" Height="11" Canvas.Left="106" Canvas.Top="65" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#49000000" />         
<Ellipse Width="10" Height="10" Canvas.Left="104" Canvas.Top="39" Stretch="Fill" Fill="DarkGoldenrod" OpacityMask="#27000000" />         
<Ellipse Width="21.835" Height="21.862" Canvas.Left="47.2783" Canvas.Top="0.5" Stretch="Fill" Fill="DarkGoldenrod"></Ellipse>

<Canvas.RenderTransform>         
<RotateTransform x:Name="SpinnerRotate" Angle="0" />         
</Canvas.RenderTransform>         
<Canvas.Triggers>

<EventTrigger RoutedEvent="ContentControl.Loaded">         
<BeginStoryboard>         
<Storyboard>   

<DoubleAnimation Storyboard.TargetName="SpinnerRotate" Storyboard.TargetProperty="(RotateTransform.Angle)" From="0" To="360" Duration="0:0:01" RepeatBehavior="Forever" />  

</Storyboard>         
</BeginStoryboard>         
</EventTrigger>         
</Canvas.Triggers>         
</Canvas>
于 2013-03-20T20:36:17.887 回答