c# - Get value for Style from property of the instance to be styled -
I would like to create elements during the runtime and will add them to a style.
Looking at the following Xaml, I would like to bind the value to the property center
the actual values of a style object (see main method). I tried different binding notes but without success (probably because I'm still new to xaml) I tried to change just the center
on this example but the examples are frozen and it can not be changed.
& lt; Window x: name = "window" x: class = "circularing manwindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft .com / winfx / 2006 / xaml "title =" main window "height =" 350 "width =" 525 "& gt; & Lt; Window.Resources & gt; & Lt; Style x: Key = "AlertBubble" TargetType = "{x: type path}" & gt; & Lt; Setter Property = "Stroke Exposure" Value = "0" /> & Lt; Setter Property = "Data" & gt; & Lt; Setter.Value & gt; & Lt ;! - How can I share the center in a 'style' example tag property? - & gt; & Lt; EllipseGeometry x: name = "circle" center = "200,200" RadiusX = "100" RadiusY = "100" & gt; & Lt; / EllipseGeometry & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; Setter Property = "Fill" & gt; & Lt; Setter.Value & gt; & Lt; RadialGradientBrush & gt; & Lt; GradientStop Color = "Black" /> & Lt; GradientStop color = "# 2F5CB2" /> & Lt; / RadialGradientBrush & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; Setter Property = "Opacity Mask" & gt; & Lt; Setter.Value & gt; & Lt; RadialGradientBrush & gt; & Lt; GradientStop color = "# 00000000" offset = "0.5" /> & Lt; GradientStop color = "#FFFFFFF" offset = "1" /> & Lt; / RadialGradientBrush & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; /Window.Resources> & Lt; / Window & gt;
My main
method:
initial group (); Random R = New Random (); For (Int i = 0; I <500; i ++) {var path = New path (); Int Position X = R. Unux (1400); Int position w = r Next (800); Path Tag = new point (position X, position Y); Path Style = (style) it Resources ["Alertbubble"]; }
Now I would like the following to be true: (EllipseGeometry path.Data). Center.Y == positionY
. What binding expression should you use?
You mark relativeSource
markup extension and parents Find the path example object like this:
& lt; EllipseGeometry x: name = "circle" center = "{binding tag, relative source = {relative source mode = FindAncestor, AncestorType = path}}" RadiusX = "100" RadiusY = "100" />
Comments
Post a Comment