使用MahApps.Metro主题覆盖Expander ToggleButton样式

时间:2020-07-15 15:07:00

标签: wpf xaml mahapps.metro

我正在使用MahApps.Metro样式化WPF应用程序。在某些地方,我使用<Expander>作为弹出菜单。

但是,切换箭头的默认方向在逻辑上是向后的(它显示当前状态,而不是单击按钮的作用)。

因此,目前尚未扩展:

not expanded

这已展开:

expanded

我想交换这些,以使扩展点位于左侧,而不是向右扩展。我不能使用ExpandDirection="Right",因为标题不正确。

默认样式在这里:https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/Styles/Controls.Expander.xaml-我不想将其全部粘贴在这里,因为它很长。

我的理解是,我要做的所有改变箭头方向的工作就是将RotateTransform AngleMahApps.Styles.ToggleButton.ExpanderHeader.Left中的MahApps.Styles.ToggleButton.ExpanderHeader.Right从90更改为-90,反之亦然。

我可以只覆盖该样式的这一特定部分,而不影响其他所有内容吗?

目前,如果我在App.xaml中创建新样式,则可以反转箭头方向,但是我丢失了所有想要保留的主题(颜色等)。

1 个答案:

答案 0 :(得分:1)

您可以使用string hdnStartTime = Start; string hdnEndTime = End; string hdnAgent = Agent; string hdnCampaign = Campaign; string hdnCompany = Company; string hdnPhone = Phone; string SearchQuery = "SELECT custom_view.users.Full_Name as 'Agent', CompanyName as 'Company', phone_number as 'Phone Number', start_time as 'Call Date', length_in_min as 'Length', campaign_name as 'Campaign', status_combined.status_name as 'Disposition', location FROM custom_view.recording_log left join custom_view.custom_fields_data on custom_fields_data.lead_id = custom_view.recording_log.lead_id left join UtilityHiveDev.Company on CompanyID = custom_fields_data.custom_1 left join custom_view.users on custom_view.users.user = recording_log.user left join custom_view.campaigns on campaigns.campaign_id = recording_log.campaign_id left join custom_view.status_combined on status_combined.status = recording_log.status where start_time like '%" + hdnStartTime + "%' and end_time like '%" + hdnEndTime + "%' and custom_view.users.Full_Name like '%" + hdnAgent + "%' and campaign_name like '%" + hdnCampaign + "%' and CompanyName like '%" + hdnCompany + "%' and phone_number like '%" + hdnPhone + "%' order by start_time desc;"; 为左侧展开方向设置右侧标题样式:

ExpanderHelper

命名空间为<Expander IsExpanded="False" ExpandDirection="Left" Height="200" mah:ExpanderHelper.HeaderLeftStyle="{DynamicResource MahApps.Styles.ToggleButton.ExpanderHeader.Right}"> </Expander>