WPF How do I align buttons on the right with x number of buttons -


i trying align buttons on right of dockpanel, hide , show buttons based on certian criteria. in need of howto right justify based on shown. using this:

    <dockpanel horizontalalignment="stretch" height="34" margin="0,0,2,35" verticalalignment="bottom">         <button dockpanel.dock="right" height="23" x:name="btnone" click="btnone_click" margin="0,0,5,5" verticalalignment="bottom" horizontalalignment="right" width="auto">             <textblock x:name="txtbtnonetext" />         </button>         <button dockpanel.dock="right" height="23" width="auto" x:name="btntwo" visibility="hidden" click="btntwo_click" horizontalalignment="right" margin="0,0,5,5" verticalalignment="bottom">             <textblock x:name="txtbtntwotext" />         </button>     </dockpanel> 

when show button btnone want right justified, when show btntwo want right justified, or when show both of them btnone on farmost right , btntwo 5px left of btnone.

thanks!

instead of dockpanel try using stackpanel -

        <stackpanel grid.row="0" orientation="horizontal">             <button x:name="btn1" content="btn1" height="34" />             <button x:name="btn2" margin="5,0,0,0" content="btn2" height="34" />         </stackpanel> 

and set visibility of button collapsed instead of hidden when want 1 button hide , won't take space reserved it. whereas if set visibility hidden wont shown on ui still take space reserved it.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -