question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to Change color of Progress bar

See original GitHub issue

I Wish to use this progress bar, but i don’t know how to change the color of this, to Black but i failed to use " foreground color " when I was trying to use this style.

image

This error shows up

image

System.InvalidOperationException
  HResult=0x80131509
  Message='[Unknown]' property does not point to a DependencyObject in path '(0).(1).(2)[1].(3)'.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Media.Animation.Storyboard.VerifyPathIsAnimatable(PropertyPath path)
   at System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer)
   at System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer)
   at System.Windows.Media.Animation.Storyboard.BeginCommon(DependencyObject containingObject, INameScope nameScope, HandoffBehavior handoffBehavior, Boolean isControllable, Int64 layer)
   at System.Windows.Media.Animation.BeginStoryboard.Begin(DependencyObject targetObject, INameScope nameScope, Int64 layer)
   at System.Windows.StyleHelper.InvokeEventTriggerActions(FrameworkElement fe, FrameworkContentElement fce, Style ownerStyle, FrameworkTemplate frameworkTemplate, Int32 childIndex, RoutedEvent Event)
   at System.Windows.StyleHelper.ExecuteEventTriggerActionsOnChild(Object sender, RoutedEventArgs e)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Interop.HwndTarget.OnResize()
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

Here is the Code I used.

  <ProgressBar HorizontalAlignment="Left" Foreground="Azure" Value="50" Style="{StaticResource ProgressBarPrimaryStripe}" Height="18.8" Margin="542.4,410.4,0,0" VerticalAlignment="Top" Width="211.6">
        <ProgressBar.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </ProgressBar.RenderTransform>
        </ProgressBar>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
NaBiancommented, Oct 31, 2019

just use these codes :

<ProgressBar Style="{StaticResource ProgressBarPrimaryStripe}" Value="50">
    <ProgressBar.Resources>
        <Color x:Key="DarkPrimaryColor">Black</Color>
    </ProgressBar.Resources>
</ProgressBar>
1reaction
ghost1372commented, Oct 31, 2019

@AdarshRise you can do like this

<ProgressBar Value="50" Style="{StaticResource ProgressBarPrimaryStripe}">
           <ProgressBar.Foreground>
               <DrawingBrush Viewport="0,0,20,32" TileMode="Tile" ViewportUnits="Absolute" Stretch="None">
                   <DrawingBrush.Transform>
                       <TransformGroup>
                           <RotateTransform Angle="20"/>
                           <TranslateTransform x:Name="MyTransform" X="0"/>
                       </TransformGroup>
                   </DrawingBrush.Transform>
                   <DrawingBrush.Drawing>
                       <GeometryDrawing>
                           <GeometryDrawing.Brush>
                               <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
                                   <GradientStop Color="Black" Offset="0"/>
                                   <GradientStop Color="Black" Offset="0.5"/>
                                   <GradientStop Color="White" Offset="0.5"/>
                                   <GradientStop Color="White" Offset="1"/>
                               </LinearGradientBrush>
                           </GeometryDrawing.Brush>
                           <GeometryDrawing.Geometry>
                               <RectangleGeometry Rect="0,0,20,32"/>
                           </GeometryDrawing.Geometry>
                       </GeometryDrawing>
                   </DrawingBrush.Drawing>
               </DrawingBrush>
           </ProgressBar.Foreground>
       </ProgressBar>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Set Color of Progress Bar using HTML and CSS
By default, it looks gray. However, to make the progress bars stand out and look visually appealing, their color can be changed using...
Read more >
How to Set Color of Progress Bar using HTML and CSS
Example 2: In this example, we will set the color and background color of progress bar. HTML. HTML ...
Read more >
How can I change the color of a progress bar value in HTML?
Instead of making your own progress bar, you can simply use the accent-color variable instead of color or background . progress { width:...
Read more >
CSS Awesome Trick: How to Create a Progress Bar That ...
If the progress is between 80% and 100%, set the background color to green. · If the progress is between 60% and 80%,...
Read more >
The HTML5 progress Element
The progress bar color is blue in all the versions of Internet Explorer. Opera 11 and 12 doesn't permit changing the progress bar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found