Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with drawing from code
    primarykey
    data
    text
    <p>I have XAML that draws an arrow and I've tried unsuccessfully to convert this XAML to code: the upper arrow is the XAML and the lower is the code.</p> <p>Can someone tell me what have I done wrong in the code ? I would like it to looks exactly like the XAML one.</p> <p><img src="https://i.stack.imgur.com/DMDS6.png" alt="enter image description here"></p> <p>XAML:</p> <pre><code> &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="*" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Rectangle&gt; &lt;Rectangle.Fill&gt; &lt;DrawingBrush Stretch="Uniform"&gt; &lt;DrawingBrush.Drawing&gt; &lt;DrawingGroup&gt; &lt;DrawingGroup.Children&gt; &lt;GeometryDrawing Geometry="F1 M 3.64665,5.62366C 5.73362,3.09485 8.89196,1.48303 12.4268,1.48303C 16.1132,1.48303 19.3901,3.23596 21.4694,5.95398"&gt; &lt;GeometryDrawing.Pen&gt; &lt;Pen Thickness="2.4" LineJoin="Round" Brush="Black"/&gt; &lt;/GeometryDrawing.Pen&gt; &lt;/GeometryDrawing&gt; &lt;GeometryDrawing Geometry="F1 M 21.4719,1.21204L 21.4719,5.96594L 16.7181,5.96594"&gt; &lt;GeometryDrawing.Pen&gt; &lt;Pen Thickness="2.4" MiterLimit="2.75" Brush="Black"/&gt; &lt;/GeometryDrawing.Pen&gt; &lt;/GeometryDrawing&gt; &lt;GeometryDrawing Brush="Black" Geometry="F1 M 21.4593,0.00012207C 22.122,0.00012207 22.6593,0.537231 22.6593,1.20007C 22.6593,1.86267 22.122,2.40002 21.4593,2.40002C 20.7966,2.40002 20.2593,1.86267 20.2593,1.20007C 20.2593,0.537231 20.7966,0.00012207 21.4593,0.00012207 Z "/&gt; &lt;GeometryDrawing Brush="Black" Geometry="F1 M 16.7121,4.76526C 17.3749,4.76526 17.9121,5.30261 17.9121,5.96545C 17.9121,6.62805 17.3749,7.16516 16.7121,7.16516C 16.0494,7.16516 15.5121,6.62805 15.5121,5.96545C 15.5121,5.30261 16.0494,4.76526 16.7121,4.76526 Z "/&gt; &lt;/DrawingGroup.Children&gt; &lt;/DrawingGroup&gt; &lt;/DrawingBrush.Drawing&gt; &lt;/DrawingBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;Image x:Name="img" Grid.Row="1"/&gt; &lt;/Grid&gt; </code></pre> <p>Code behind:</p> <pre><code> public partial class Window1 : Window { public Window1() { InitializeComponent(); img.Source = _createInnerIcon(); } private DrawingImage _createInnerIcon() { SolidColorBrush lineBrush = Brushes.Black; var dGroup = new DrawingGroup(); using (DrawingContext dc = dGroup.Open()) { dc.DrawGeometry(lineBrush, new Pen(lineBrush, 2.4) { LineJoin = PenLineJoin.Round }, Geometry.Parse("F1 M 3.64665,5.62366C 5.73362,3.09485 8.89196,1.48303 12.4268,1.48303C 16.1132,1.48303 19.3901,3.23596 21.4694,5.95398")); dc.DrawGeometry(lineBrush, new Pen(lineBrush, 2.4) { MiterLimit = 2.75 }, Geometry.Parse("F1 M 21.4719,1.21204L 21.4719,5.96594L 16.7181,5.96594")); dc.DrawGeometry(lineBrush, new Pen(lineBrush, 1), Geometry.Parse("F1 M 21.4593,0.00012207C 22.122,0.00012207 22.6593,0.537231 22.6593,1.20007C 22.6593,1.86267 22.122,2.40002 21.4593,2.40002C 20.7966,2.40002 20.2593,1.86267 20.2593,1.20007C 20.2593,0.537231 20.7966,0.00012207 21.4593,0.00012207 Z ")); dc.DrawGeometry(lineBrush, new Pen(lineBrush, 1), Geometry.Parse("F1 M 16.7121,4.76526C 17.3749,4.76526 17.9121,5.30261 17.9121,5.96545C 17.9121,6.62805 17.3749,7.16516 16.7121,7.16516C 16.0494,7.16516 15.5121,6.62805 15.5121,5.96545C 15.5121,5.30261 16.0494,4.76526 16.7121,4.76526 Z ")); } return new DrawingImage(dGroup); } } </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.
 

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