Reputation: 57
Is there a way to increase the thickness of the progressbar when using the circular style? I can't find any documentation about it on github.
Upvotes: 2
Views: 3547
Reputation: 157
The way I get around this, without doing anything outside XAML or modifying the template, is to use a combination of:
Example below, I generally play around with the split between scale and width/height until I'm happy with how it looks.
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Width="50" Height="50">
<ProgressBar.LayoutTransform>
<ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2" />
</ProgressBar.LayoutTransform>
</ProgressBar>
Upvotes: 5
Reputation: 57
Based on Robert Harvey answer, I found a better solution. Instead of copying the whole style, and change the hardcoded value by another hardcoded value, I created a behavior to change the thickness value.
public class CircularProgressBarBehavior : StyleBehavior<ProgressBar, CircularProgressBarBehavior>
{
public static readonly DependencyProperty StrokeThicknessProperty =
DependencyProperty.RegisterAttached("StrokeThickness", typeof(double), typeof(CircularProgressBarBehavior), new PropertyMetadata(3d));
public static double GetStrokeThickness(DependencyObject dependencyObject)
{
return (double) dependencyObject.GetValue(StrokeThicknessProperty);
}
protected override void OnAttached()
{
base.OnAttached();
// ReSharper disable once CompareOfFloatsByEqualityOperator
var path = AssociatedObject.GetChildren<Path>().FirstOrDefault(e => e.Name.Equals("Path"));
if (path != null)
path.StrokeThickness = GetStrokeThickness(AssociatedObject);
}
public static void SetStrokeThickness(DependencyObject dependencyObject, double value)
{
dependencyObject.SetValue(StrokeThicknessProperty, value);
}
}
Upvotes: 1