wpf - Positioning UIElement in Custom Control -
i developing custom control, there textbox , button placed inside grid.
the thing when set custom property usercontrol - left : button should displayed before textbox, , right button should displayed on right side of text box.
since, defining both elements in grid - not able position per requirements.
if have use grid, can make grid have 3 columns , switch textbox grid.column based on custom property.
<grid> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="*" /> <columndefinition width="auto" /> </grid.columndefinitions> <button grid.column="1" content="some text" /> <textbox text="test"> <textbox.style> <style targettype="{x:type textbox}"> <setter property="grid.column" value="0" /> <style.triggers> <datatrigger binding="{binding relativesource={relativesource findancestor, ancestortype={x:type usercontrol}}, path=left}" value="true"> <setter property="grid.column" value="2" /> </datatrigger> </style.triggers> </style> </textbox.style> </textbox> </grid> you can switch {x:type usercontrol} in datatrigger {x:type customusercontrol}
Comments
Post a Comment