c# - XAML Binding to Element in a style -
i adding entitycontrol
edgecontrol
. edgecontrol
contains element named part_edgepath
. trying bind element within entitycontrol
:
<usercontrol x:class="ui.graph.entitycontrol" ... > <ellipse width="15" height="15" fill="blue"> <ellipse.rendertransform> <transformgroup> <translatetransform x="-7.5" y="-7.5" /> <!-- use radius shift circle path --> <translatetransform x:name="animatedtranslatetransform"/> </transformgroup> </ellipse.rendertransform> <ellipse.triggers> <eventtrigger routedevent="binding.targetupdated"> <beginstoryboard> <storyboard repeatbehavior="forever" > <doubleanimationusingpath source="x" duration="{binding path=duration}" storyboard.targetproperty="x" storyboard.targetname="animatedtranslatetransform" pathgeometry="{binding elementname=part_edgepath, path=data, mode=oneway, notifyontargetupdated=true, converter={staticresource geometrytopathgeometry}}"/> <doubleanimationusingpath source="y" duration="{binding path=duration}" storyboard.targetproperty="y" storyboard.targetname="animatedtranslatetransform" pathgeometry="{binding elementname=part_edgepath, path=data, mode=oneway, notifyontargetupdated=true, converter={staticresource geometrytopathgeometry}}"/> </storyboard> </beginstoryboard> </eventtrigger> </ellipse.triggers> </ellipse> </usercontrol>
the source element located in contenttemplate in style. worked when had entitycontrol
inside style well:
<resourcedictionary ... > <!-- edge control --> <style targettype="{x:type gxl:edgecontrol}"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type gxl:edgecontrol}"> <canvas x:name="edgecanvas"> <path stroke="{templatebinding foreground}" strokethickness="2" minwidth="1" minheight="1" tooltip="{templatebinding tooltip}" x:name="part_edgepath"/> <path stroke="{templatebinding foreground}" strokethickness="2" minwidth="1" minheight="1" x:name="part_edgearrowpath"/> <!-- here entitycontrol part of style --> <!--<ellipse ... />--> </canvas> </controltemplate> </setter.value> </setter> </style> </resourcedictionary>
i create entitycontrol
in code programmatically:
entitycontrol entity = new entitycontrol(); canvas canvas = visualtreehelper.getchild(edgecontrol, 0) canvas; canvas.children.add(entity); entity.initializecomponent(); entity.updatelayout();
unfortunately doubleanimationusingpath.pathgeometry
of entitycontrol
empty. tried many things make work failed. clarification why doesn't work , how could/should make work highly appreciated!
thanks!
Comments
Post a Comment