silverlight垂直进度条

发布于 2024-10-22 12:06:44 字数 2132 浏览 5 评论 0原文

我不明白我做错了什么。我有一个用户控件,它有一个垂直进度条,其下方有一个标签。

<UserControl x:Class="IFramedInBrowser.Code"
    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"
    mc:Ignorable="d" Height="150" Width="15">

    <Grid Width="120" Height="15" >
        <StackPanel Width="120" Height="15" >
            <ProgressBar Grid.Row="0" Value="{Binding Path=Percent}"  Maximum="100" Width="120" Height="15" />
        </StackPanel>
        <TextBlock Grid.Row="1" Height="30" HorizontalAlignment="Left"  Name="textBlock1" Text="{Binding Path=Symbol.Name}" VerticalAlignment="Top" >
            <TextBlock.RenderTransform>
                <RotateTransform Angle="90"/>
            </TextBlock.RenderTransform>
        </TextBlock>
        <Grid.RenderTransform>
                <RotateTransform Angle="-90"/>
        </Grid.RenderTransform> 
        </Grid>
</UserControl>

然后这个用户控件在 ItemsControl 中使用

<ItemsControl x:Name="HorizontalListBox"  
                      ItemsSource="{Binding Source={StaticResource MyViewModel}, Path=List}" 
                      HorizontalAlignment="Stretch" 
                      HorizontalContentAlignment="Center" Height="150" 
                      >
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <my:Code DataContext="{Binding}">

                    </my:Code>
                </DataTemplate>
            </ItemsControl.ItemTemplate>

        </ItemsControl>

它最后看起来应该像钢琴键盘...... 旋转变换后,进度条被砍断......我做错了什么?如何解决这个问题?

I can not figure out what I did wrong. I have a Usercontrol that has a vertical progressbar and under it a label.

<UserControl x:Class="IFramedInBrowser.Code"
    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"
    mc:Ignorable="d" Height="150" Width="15">

    <Grid Width="120" Height="15" >
        <StackPanel Width="120" Height="15" >
            <ProgressBar Grid.Row="0" Value="{Binding Path=Percent}"  Maximum="100" Width="120" Height="15" />
        </StackPanel>
        <TextBlock Grid.Row="1" Height="30" HorizontalAlignment="Left"  Name="textBlock1" Text="{Binding Path=Symbol.Name}" VerticalAlignment="Top" >
            <TextBlock.RenderTransform>
                <RotateTransform Angle="90"/>
            </TextBlock.RenderTransform>
        </TextBlock>
        <Grid.RenderTransform>
                <RotateTransform Angle="-90"/>
        </Grid.RenderTransform> 
        </Grid>
</UserControl>

This usercontrol is then used in a ItemsControl

<ItemsControl x:Name="HorizontalListBox"  
                      ItemsSource="{Binding Source={StaticResource MyViewModel}, Path=List}" 
                      HorizontalAlignment="Stretch" 
                      HorizontalContentAlignment="Center" Height="150" 
                      >
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <my:Code DataContext="{Binding}">

                    </my:Code>
                </DataTemplate>
            </ItemsControl.ItemTemplate>

        </ItemsControl>

It should look like a piano keybord at the end...
After the rotation transformation the progressbar is chopped... What did I dowrong? How to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-10-29 12:06:44

您可以尝试为所有控件添加不同的背景颜色,以了解控件的大小。

此外,SilverlightSpy 现在是免费的只读,您可以在运行时浏览真实的可视化树。

无论如何,我建议通过自定义其模板来更改 ProgressBar 的方向。

You can try to add different background colors to all controls to find out sizes of controls.

Also SilverlightSpy is now free for read only and you can go through the real visual tree at runtime.

Anyway, I would suggest to change the orientation of ProgressBar by customizing its template.

月亮是我掰弯的 2024-10-29 12:06:44

这是一个剪辑问题。您在各处设置了太多的高度和宽度,并且很难知道哪一个控制尺寸。此外,ListBox 中的堆叠适用于布局,而 RotateTransform 仅对最终视觉通道有效,因此它会旋转剪辑的进度条。

您应该遵循 jumbo 的建议,通过修改模板而不是通过旋转来创建垂直进度条。

如果您不想创建模板,则需要删除 UserControl 中的主网格并使用 Canvas 代替。画布不会被剪裁。它们让你的元素自由浮动,这可能就是你想要的。

This is a clipping issue. You are setting too many heights and widths everywhere and it's confusing to know which one is in control of dimensions. Also, the stacking in the ListBox works on the layout and the RotateTransform is only effective on the final visual pass, so it's rotating a clipped progress bar.

You should follow jumbo's advice and create a vertical progress bar by modifying the template, not by rotation.

If you don't want to create the template, then you need to remove the main Grid you have in the UserControl and use a Canvas instead. Canvases don't clip. They let your elements float freely, which is probably what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文