Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your VisualBrush is designed to be assigned to an object that accepts a Brush, like a Background not a Style like you are attempting to. I would suggest that you do some thing like this.(<em>This example will assign the same <code>VisualBrush</code> to every <code>TextBox</code> if you need to be able to pick and choose your brushes then I would suggest that you add back the <code>x:Key</code> to your style and assign the Styles individually to your TextBox's</em>)</p> <pre><code>&lt;Window x:Class="WpfApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="400" Width="400"&gt; &lt;Window.Resources&gt; &lt;VisualBrush x:Key="myVisualBrush"&gt; &lt;VisualBrush.Visual&gt; &lt;Canvas&gt; &lt;Path Fill="#FF231F20" Stretch="Fill" Width="12.69" Height="14.477" Canvas.Left="652.196" Canvas.Top="88.61" Data="F1M617.2051,52.7275C616.7281,52.4525,616.3391,52.6775,616.3391,53.2275L616.3391,66.4695C616.3391,67.0195,616.7281,67.2445,617.2051,66.9695L628.6721,60.3485C629.1481,60.0735,629.1481,59.6235,628.6721,59.3485z"/&gt; &lt;/Canvas&gt; &lt;/VisualBrush.Visual&gt; &lt;/VisualBrush&gt; &lt;Style TargetType="{x:Type TextBox}"&gt; &lt;Setter Property="Background" Value="{StaticResource myVisualBrush}"/&gt; &lt;/Style&gt; &lt;Style x:Key="myPathStyle" TargetType="{x:Type Path}"&gt; &lt;Setter Property="Fill" Value="{StaticResource myVisualBrush}"/&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;TextBox x:Name="MyTextBox" /&gt; &lt;Path Style="{StaticResource myPathStyle}" x:Name="myPath" &gt; &lt;Path.Data&gt; &lt;RectangleGeometry Rect="100,100,100,100"/&gt; &lt;/Path.Data&gt; &lt;/Path&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre>
    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.
 

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