c# - WPF custom control - reach element inside, rotate only part of custom control -
i have problem custom control. have custom controls, have 5-8 paths, user can "select". of paths want have label (inside custom control), can change content inside (from window, use custom control). xaml of custom control looks like:
<firstmolartooth ..........> <dockpanel> <label name="lbl_tooth" dockpanel.dock="top" fontsize="10" horizontalalignment="center" /> <grid dockpanel.dock="bottom" horizontalalignment="center"> <path ......./> </grid> </dockpanel> </firstmolartooth>
how can reach label inside window use custom control?? like:
<local:firstmolartooth x:name="tooth_15" ........> <lbl_tooth content="15" /> </local:firstmolartooth>
or
<local:firstmolartooth .... content="15"> </local:firstmolartooth>
second problem rotate custom control in window use with:
<local:firstmolartooth ....> <local:firstmolartooth.layouttransform> <rotatetransform centerx="0.5" centery="0.5" angle="180"/> </local:firstmolartooth.layouttransform> </local:firstmolartooth>
my problem when (logically), rotate whole control (with label). want rotate paths , not label. thought can custom property label "isrotated" , when setted on true, should "reset" rotate (set angle 0) triggers. not able that. (should reach custom property xaml? or in code? maybe problem try reach xaml).
i know can delete label custom control , have in there paths , after rotate paths , label have in window. user can select "whole" custom control (select tooth) , can select "segment" of tooth (paths). therefore have inside custom control.
thanks advice.
for first problem, bind lbl_tooth against firstmolartooth content property. if doesn't work, create new dependency property inside firstmolartooth(of string) , bind against it. can change property later outside of custo control.
<firstmolartooth x:name="molar" ..........> <dockpanel> <label name="lbl_tooth" dockpanel.dock="top" fontsize="10" horizontalalignment="center" content="{binding content, elementname=molar}" /> <grid dockpanel.dock="bottom" horizontalalignment="center"> <path ......./> </grid> </dockpanel>
for second problem, make new dependency property of type doubule can set outside. creating dependency properties, can either google or search forum. millions of answers.
<firstmolartooth x:name="molar" ..........> <dockpanel> <label name="lbl_tooth" dockpanel.dock="top" fontsize="10" horizontalalignment="center" content="{binding content, elementname=molar}" /> <grid dockpanel.dock="bottom" horizontalalignment="center"> <path .......> <path.layouttransform> <rotatetransform centerx="0.5" centery="0.5" angle="{binding yournewangleproperty, elementname=molar}"/> </path.layouttransform> </path> </grid> </dockpanel>
Comments
Post a Comment