Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom ProgressBar ControlTemplate
    text
    copied!<p>I am having a little difficulty with a generic template for my extended progress control. Basically, the template consists of a grid, with some text information and the actual progress bar.</p> <p>It works fine, except for when I want to switch to vertical orientation. Everything appears to be rotated correctly, but I get no progress indicator. I hope its something silly I'm overlooking, and just need a second set of eyes to see...</p> <p>Here is the template:</p> <pre><code>&lt;ControlTemplate TargetType="{x:Type local:MyProgressControl}"&gt; &lt;Grid x:Name="gridLayout" Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" MinHeight="20" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;StackPanel x:Name="stackLabels" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal"&gt; &lt;TextBlock x:Name="txtProgress" Style="{Binding TextBlockStyle, RelativeSource={RelativeSource TemplatedParent}}" Margin="3,1" Text="{Binding IndicationText, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding ShowIndicationText, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibility}}" /&gt; &lt;TextBlock x:Name="txtValue" Style="{Binding TextBlockStyle, RelativeSource={RelativeSource TemplatedParent}}" Margin="3,1" Text="{Binding RoundedValue, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding ShowProgressText, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibility}}" /&gt; &lt;TextBlock x:Name="txtOf" Style="{Binding TextBlockStyle, RelativeSource={RelativeSource TemplatedParent}}" Margin="3,1" Text="/" Visibility="{Binding ShowProgressText, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibility}}" /&gt; &lt;TextBlock x:Name="txtMaximum" Style="{Binding TextBlockStyle, RelativeSource={RelativeSource TemplatedParent}}" Margin="3,1" Text="{Binding RoundedMaximum, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding ShowProgressText, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibility}}" /&gt; &lt;/StackPanel&gt; &lt;Border x:Name="PART_Track" Grid.Row="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="8"&gt; &lt;Border.Background&gt; &lt;LinearGradientBrush x:Name="trackBrush" StartPoint="0.5, 0" EndPoint="0.5, 1"&gt; &lt;GradientStop Offset="0.0" Color="#6A6A6A" /&gt; &lt;GradientStop Offset="0.2" Color="#949494" /&gt; &lt;GradientStop Offset="0.35" Color="#A9A9A9" /&gt; &lt;GradientStop Offset="0.55" Color="#D3D3D3" /&gt; &lt;GradientStop Offset="0.65" Color="#949494" /&gt; &lt;GradientStop Offset="1.0" Color="#3F3F3F" /&gt; &lt;/LinearGradientBrush&gt; &lt;/Border.Background&gt; &lt;Decorator x:Name="PART_Indicator" Margin="1" HorizontalAlignment="Left" VerticalAlignment="Stretch"&gt; &lt;Border x:Name="borderIndicator" Background="{TemplateBinding BackgroundBrush}" CornerRadius="{Binding ElementName=PART_Track, Path=CornerRadius}" /&gt; &lt;/Decorator&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="Orientation" Value="Vertical"&gt; &lt;Setter Property="LayoutTransform" TargetName="gridLayout"&gt; &lt;Setter.Value&gt; &lt;RotateTransform Angle="90" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="LayoutTransform" TargetName="PART_Track"&gt; &lt;Setter.Value&gt; &lt;RotateTransform Angle="-90" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="HorizontalAlignment" TargetName="PART_Indicator" Value="Stretch" /&gt; &lt;Setter Property="VerticalAlignment" TargetName="PART_Indicator" Value="Bottom" /&gt; &lt;Setter Property="LayoutTransform" TargetName="PART_Indicator"&gt; &lt;Setter.Value&gt; &lt;RotateTransform Angle="-90" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="HorizontalAlignment" TargetName="borderIndicator" Value="Stretch" /&gt; &lt;Setter Property="VerticalAlignment" TargetName="borderIndicator" Value="Bottom" /&gt; &lt;Setter Property="LayoutTransform" TargetName="borderIndicator"&gt; &lt;Setter.Value&gt; &lt;RotateTransform Angle="-90" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; </code></pre> <p>Thanks, wTs</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload