【发布时间】:2011-11-18 16:28:36
【问题描述】:
我在我的应用程序中使用了一个进度条,这个进度条是在用户控件中定义的,例如:
UserControl x:Class="StirLibrary.ProgressBarControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Height="800">
<Border BorderThickness="2" BorderBrush="Transparent" Background="Transparent" Margin="50,522,50,158">
<StackPanel>
<TextBlock Text="Loading..." Name="loading" Grid.Row="1" HorizontalAlignment="Center" Height="30" Foreground="Green">
</TextBlock>
<ProgressBar Background="Transparent" Margin="10, 0, 0, 10" Height="80" HorizontalAlignment="Center" Name="progressBar1" VerticalAlignment="Top" Width="380" Grid.Row="2" HorizontalContentAlignment="Left" IsHitTestVisible="True" VerticalContentAlignment="Top" Value="0" Maximum="100">
</ProgressBar>
</StackPanel>
</Border>
</Grid>
</UserControl>
我的问题是当我的应用程序的方向变为横向时,进度条的方向不会改变,这会使应用程序看起来很丑。欢迎任何建议如何避免这种情况并使进度条按方向显示。
【问题讨论】:
-
如何显示用户控件?如果它在弹出窗口中,则这是弹出窗口的已知问题。
-
我知道这不能回答您的问题,但也许您会考虑使用由操作系统处理的 ProgressIndicator,它是显示进度的标准:msdn.microsoft.com/en-us/library/…。否则,我还会考虑查看 Silverlight 工具包中的 PerformanceProgressBar,据说它在某些方面比开箱即用的 ProgressBar 更好。
-
@Matt Am 在弹出窗口中显示用户控件。我的问题是我的整个解决方案有 3 个项目 UI 部分、库部分和调度程序部分。这个进度条控件在库部分和我无法在我的 UI 部分中访问它,我在其中调用事件以更改方向。我知道我的问题的部分解决方案..即,包含进度条的堆栈面板必须旋转 90 度并且(渲染变换原点)当方向改变时必须为堆栈面板定义,因为我无法访问堆栈面板元素无法实现我所知道的......
标签: xaml windows-phone-7 user-controls progress-bar