WPF : using a designed vector image as a control template in WPF -
I am exploring the idea of using professional vector images as ControlTemplates in my WPF application. The idea is to create many types of controls, each with a different visual design, which can then be drawn and left, this is exactly the same case-case that is a visual designer (Ella Vicio)
< P> I have the following XAML It defines a control template with a target type button, and I have a button that uses this template. I want to know how I can modify this template so that it uses the height and width of the button. I feel as though the template is related to the top-left corner renders (I take the button image moves) but it takes an account of the dimensions of the button, so it has its own "ready" shape. Do not talk about what I do & lt; Window X: class = "Euphrosyne.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation "Xmlns: x =" http://schemas.microsoft.com/winfx/2006/xaml "title =" Window1 "height =" 300 "width =" 300 "> & lt; Window.Resources & gt; & Lt; ControlTemplate TargetType = "{x: type button}" x: Key = "PresentBox" & gt; & lt; canvas name = "SVG2" & gt; Canvas.Resources /> & lt; canvas name = "Layer 1" & gt; & lt; pathname = "path2385" Fill = "# D45500" stroke = "# FF000000 "StrokeThickness =" 1px "StrokeLineJoin =" miter "StrokeEndLineCap =" flat "data =" m 110 82.362,183 one 40 30 1 1 39,041709 63,365048 l70 82.362183 h "/> & gt; Lt; fill path name = "path 2387" = "# ff 20000" data = "m 100 100 l 79.96762 89.419767 l 59.895213 99.923868 L 63.767267 77.602471 L 47.574559 61.758424 L. 69.999 999 58.543274 L 80.064762 38.247014 L 90.052393 58.581339 L 112.46547 61.881608 L 96.212721 77.664061 L 100 100 "/> & Lt; Fill name path = "path 2389" = "# C83737" = "M 100 40.000002 L 97.601178 65.149257 L 92.298 9 63 86.872981 L 82.841672 110.29944 L70 88.543275 L 44.797648 86.788031 L 61.520697 67.85185 L 55.402078 43.340588 L 78.579163 53.393551 L 100 40.000002 Z "& gt; & Lt; -! Path - & gt; & Lt; / Path & gt; & Lt; / Canvas & gt; & Lt; / Canvas & gt; & Lt; / ControlTemplate & gt; & Lt; /Window.Resources> & Lt; Grid & gt; & Lt; Button Template = "{StaticResource PresentBox}" & gt; Hello & lt; / Button & gt; & Lt; / Grid & gt; & Lt; / Window & gt;
Wrap the canvas in one. The canvas does not correlate its own dimensions with its content, so you can see the content with the canvas, but it does not have to resize. A viewback enhances the canvas behavior by dragging its contents, when its dimensions change. You can control the behavior of the user, e.g. Horizontally, stretch, vertically or both, unfortunately, there is no limo draw, which would be good for UI controls.
Here's how it looks. Note that I'm guessing for width and height. They should match the actual path. In order to avoid leaving the countless margins, you should also make sure that the path is shaken against the X and Y axes.
& lt; Viewbox name = "View box 1" height = "200" width = "200" horizontal alignment = "left" vertical alignment = "top" stretch = "fill" & gt; & Lt; Canvas name = "layer 1" & gt; & Lt; Fill the path name = "path 2385" = "# d 45500" stroke = "# FF 2000000" strokectination = "1 px" strokeline Jain = "meter" strokeandline cap = "flat" data = "m 110 82.362183 A40 30 0 1 1 39.041709 63.365048 L70 82.362183 h "/> & Lt; Enter path name = "path 2387" = "# FF 20000" data = "M100 100 L 79.96762 89.419767 L. 59.895213 99.923868 L 63.767267 77.602471 L 47.574559 61.758424 L 69.999 999 58.543274 L 80.064762 38.247014 L 90.052393 58.581339 L 112.46547 61.881608 L 96.212721 77.664061 L 100 100 Z "/> & Lt; Fill name path = "path 2389" = "# C83737" = "M 100 40.000002 L 97.601178 65.149257 L 92.298 9 63 86.872981 L 82.841672 110.29944 L70 88.543275 L 44.797648 86.788031 L 61.520697 67.85185 L 55.402078 43.340588 L 78.579163 53.393551 L 100 40.000002 Z "/> & Lt; / Canvas & gt; & Lt; / Viewbox & gt;
Comments
Post a Comment