Issues with Rotating ProgressBar for Vertical Orientation In WinUI App

Mahdi Hosseini 155 Reputation points
2025-01-08T14:04:24.5533333+00:00

Hi,

I am working on a custom StepBar control, and the Horizontal orientation is functioning as expected.

22

However, I am encountering issues when implementing the Vertical orientation.

Since the ProgressBar control does not have an Orientation property, I am using a CompositeTransform to rotate it vertically. Here is the code snippet I am using:

<ProgressBar Name="PART_ProgressBarBack"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Center"
             RenderTransformOrigin="0.5,0.5">
    <ProgressBar.RenderTransform>
        <CompositeTransform Rotation="90" />
    </ProgressBar.RenderTransform>
</ProgressBar>

The behavior is problematic:

  1. When I resize the app, the ProgressBar's size and position change unexpectedly.
  2. If I set HorizontalAlignment="Left", the ProgressBar disappears.

000000-ezgif.com-optimize

I would like to know how to correctly rotate the ProgressBar for a vertical layout without affecting its size or position.

I have attached a sample app to demonstrate the issue.

Thank you for your assistance!

https://github.com/user-attachments/files/18348236/StepBar-Vertical-Sample.zip

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,035 questions
Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
807 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,186 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mahdi Hosseini 155 Reputation points
    2025-01-10T07:08:06.2933333+00:00

    I finally solved this problem myself. my goal was this:

    User's image

    I was changing the width of the progressbar on app sizechanged, and it seems like rotation in WinUI has issues that were resolved by changing the height of a border (instead of width) which include progressbar and using the LayoutTransform control.

    If anyone has my problems here is more information.

    https://github.com/ghost1372/DevWinUI/blob/main/dev/DevWinUI.Controls/Controls/Others/LayoutTransformer.cs

    https://github.com/ghost1372/DevWinUI/blob/49c082005284bbd03efa749d6938554edee23874/dev/DevWinUI.Controls/Controls/StepBar/StepBar.cs#L172C31-L172C37

    https://github.com/ghost1372/DevWinUI/blob/49c082005284bbd03efa749d6938554edee23874/dev/DevWinUI.Controls/Themes/Styles/Controls/StepBar.xaml#L185

    I'm also curious to know if there is a better solution without using the LayoutTransform?

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.