WPF Expander: Reversing the icon direction while keeping the content location (ExpandDirection) the same

天涯浪子 提交于 2019-12-10 10:17:27

问题


I am using the WPF expander like a drawer, it expands up out so that the header remains above the content. When it is collapsed the grid cell that it is in is made smaller as well.

I want the expand direction to remain down so that the content fills in below it, however because it moves up it would look better if the icon with the directional arrow were in the opposite direction as if the ExandDirection property were set to Up. How can this be done in either C# code or in the XAML.

Thanks


回答1:


If I understand correctly that you want to swap arrows for expander collapsed/expanded state, you'll need to create a custom control template for expander. The easiest way I know to do that is to get expander control template from wpf theme and rename styles:

  • ExpanderUpHeaderStyle to ExpanderDownHeaderStyle
  • ExpanderDownHeaderStyle to ExpanderUpHeaderStyle

You can download themes sources from here http://msdn.microsoft.com/en-us/library/aa358533(VS.90).aspx

If you'll have any issues with that, let me know what wpf theme are you using and I'll make you the xaml.

Also have a look how to customize Expander with Blend http://www.c-sharpcorner.com/uploadfile/dpatra/807/default.aspx



来源:https://stackoverflow.com/questions/3142407/wpf-expander-reversing-the-icon-direction-while-keeping-the-content-location-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!