Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes. Use a VisualBrush whose Visual is a Rectangle inside a Border to combine the other two brushes.</p> <p>Something like this:</p> <pre><code>&lt;LinearGradientBrush x:Key="UnderBrush" EndPoint="0,1"&gt; &lt;GradientStop Color="#FFFF0000" Offset="0" /&gt; &lt;GradientStop Color="#00FF0000" Offset="1" /&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="OverBrush" EndPoint="1,0"&gt; &lt;GradientStop Color="#00000000" Offset="0" /&gt; &lt;GradientStop Color="#FF000000" Offset="1" /&gt; &lt;/LinearGradientBrush&gt; &lt;VisualBrush x:Key="CombinedBrush"&gt; &lt;VisualBrush.Visual&gt; &lt;Border Background="{StaticResource UnderBrush}"&gt; &lt;Rectangle Fill="{StaticResource OverBrush}" Width="1" Height="1" /&gt; &lt;/Border&gt; &lt;/VisualBrush.Visual&gt; &lt;/VisualBrush&gt; </code></pre> <p>CombinedBrush can be used to paint your bars, and you will get the effect you describe.</p> <p><strong>Silverlight version</strong></p> <p>Since Silverlight has no VisualBrush you must build a WritableBitmap in code and use it with an ImageBrush:</p> <pre><code>&lt;ImageBrush x:Key="CombinedBrush"&gt; &lt;my:VisualBrushSimulator.Visual&gt; &lt;Border Background="{StaticResource UnderBrush}"&gt; &lt;Rectangle Fill="{StaticResource OverBrush}" Width="1" Height="1" /&gt; &lt;/Border&gt; &lt;/my:VisualBrushSimulator.Visual&gt; &lt;/ImageBrush&gt; </code></pre> <p>Here is how the VisualBrushSimulator might be implemented:</p> <pre><code>public class VisualBrushSimulator : DependencyObject { public Visual GetVisual(DependencyObject obj) { return (Visual)obj.GetValue(VisualProperty); } public void SetVisual(DependencyObject obj, Visual value) { obj.SetValue(VisualProperty, value); } public static readonly DependencyProperty VisualProperty = DependencyProperty.RegisterAttached("Visual", typeof(Visual), typeof(VisualBrushSimulator), new PropertyMetadata { PropertyChangedCallback = (obj, e) =&gt; { int width=1000; int height=1000; var bitmap = new WritableBitmap(width, height); bitmap.Render((Visual)e.NewValue, new ScaleTransform { ScaleX = width, ScaleY = height }); ((ImageBrush)obj).ImageSource = bitmap; } }); } </code></pre> <p>Note that this is not a true VisualBrush simulation, since changes to the Visual do not affect the brush.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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