-
-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to skin the StatusBar and the ToolBar using MahApps Metro #57
Comments
Hi, try to remove the styles from src\Gemini\Modules\ToolBars\Resources\Styles.xaml and see what happens. |
Hi @4ux-nbIx, thanks very much for your reply, it is most appreciated. I have also recently discovered your VS2013 theme for AvalonDock - great stuff! Thank you! I will try what you suggest after work tonight and get back to you... |
You're welcome! Also, please note that AvalonDock VS2013 theme is unfinished. There's still a lot of work to do and I don't know when I'll be able to get back to it. |
Oh, I downloaded the test application and the solution to have a look a minute ago and it looks good. Have you seen the theme used in Wild (https://github.com/chandramouleswaran/Wide/), it is very similar to your own (marked as a VS2012 theme which has light and dark versions) and could possibly be used to embellish the work you have already done? |
Yes, I've seen Wide. I wanted to fork their AvalonDock theme repository at first, but after some source code browsing I've decided that building the theme from scratch would be much easier. |
Oh, right. I would like to adopt your theme, is there anything I should be aware of before doing so? I would like to offer to do some work on it, but I am so busy I just don't think I would have time... |
No, nothing to be aware of. The theme is based on standard AvalonDock's Metro theme, so it should work fine as is, except the fact that some UI elements styles weren't updated yet. |
Brilliant. Thanks for your help. |
No problem! |
I have looked into this and merely removing the style causes more trouble than it is worth as there are binding in that view. Moreover, I want to also do this with the StatusBar which does not have a style to remove. Have you any other ideas or experience in doing this with MahApps? Thanks again... |
Off course this kind of change causes trouble. Those styles were added on purpose, right? I just wanted to make sure they do not interfere with MahApps Metro styles. They shouldn't actually, because they have the BasedOn attribute defined. The problem is that WPF doesn't see MahApps Metro resources for some reason when it constructs Gemini UI elements. I tried to define Metro resources at the application level, at the Metro demo App.xaml, but it didn't work out. I also tried to play with ThemeInfo assembly attribute and it didn't help either. This problem is quite interesting and I wanted to play with Gemini theming myself, so I am going to investigate this. |
Yeah, I have also tried to include the MahApps declarations in the App.xaml. I have also tried to put these as a resource dictionary in the MainWindow for Gemini itself to see if this would do it, but nothing. I had another play with this last night in more depth. On aspect of the solution that seems to shed some light on how to theme those controls is the the VS2010/Theme.xaml et al. which skins the StatusBar/MenuItems. In light of this I attempted to include the MahApps declarations in the Metro/Theme.xaml, but this too did not work. I would be very interested if you get this working or have any further ideas as I have spent ages on this and can't work this out! |
It's been a while since I worked on Gemini, so to help me ease back into it, please could you give me an idea of the kind of styles you want to apply? If you have a not-working-as-desired VS project you can send over, that would be ideal. I remember I wrote a |
I've dug into this a bit more, and found a couple of interesting things that might point in the direction of a solution:
I think the root of the problem with ToolBar styling is that I'm using a custom If I change ToolBarsViewModel.cs:46 to create a I'll look into getting rid of my custom |
Actually, I think I've fixed it, although the solution seems a bit... unusual. When creating the You just need to change ToolBarsViewModel.cs OnViewLoaded to this: protected override void OnViewLoaded(object view)
{
// TODO: Ideally, the ToolBarTray control would expose ToolBars
// as a dependency property. We could use an attached property
// to workaround this. But for now, toolbars need to be
// created prior to the following code being run.
var toolBarStyle = (Style) ((IToolBarsView) view).ToolBarTray.FindResource(typeof(ToolBar));
foreach (var toolBar in Items)
((IToolBarsView) view).ToolBarTray.ToolBars.Add(new ToolBarEx
{
Style = toolBarStyle,
ItemsSource = toolBar
});
base.OnViewLoaded(view);
} @Camuvingian do you mind trying this, and letting me know if it works for you? |
Hi @tgjones, thank you very much for your reply. I have tried this on Gemini and the code for the tool bar I am using in my own application and the ToolBar does not style what-so-ever. The Metro overrides are not getting applied; why this is working for you and not me is beyond me. Again, thanks very much for your time... |
Hi @tgjones, @Camuvingian, I've bee investigating this today and here's what I've found so far:
I believe all this (theme initialization time, default styles and custom markup extension) can be easily done with minimal consequences, so I'd vote for going forward with it. |
Hi @4ux-nbIx, great stuff! I have checked this solution and it seems to work very well for the Menu and the ToolBar. However, having said that, it is not applicable to the StatusBar due to the use of Tim's |
Does MahApps have any StatusBar styles? If so, |
@4ux-nbIx Where did you see the "markup extension that'll fetch resources from current app resource dictionary" being used? I've got something cobbled together in MenuItemEx, which uses |
It is not at all clear how the MahApps StatusBar is getting styled. There is no reference to "StatusBar" anywhere in the MahApps source code. In light of this, I will need to find out a bit more about how this is done and get back to you... Your point about @4ux-nbIx's solution is a fair one. |
This seems promising as a way of having a dynamic-ish I'll try it now. |
It works! I've borrowed internal static DependencyObject GetContainer(FrameworkElement frameworkElement, object item)
{
if (item is MenuItemSeparator)
return new Separator { Style = (Style)frameworkElement.FindResource(SeparatorStyleKey) };
string styleKey = (item is CheckableMenuItem) ? "CheckableMenuItem" : "MenuItem";
var result = new MenuItemEx();
result.SetResourceReference(DynamicStyle.BaseStyleProperty, typeof(System.Windows.Controls.MenuItem));
result.SetResourceReference(DynamicStyle.DerivedStyleProperty, styleKey);
return result;
} That should, at least in theory, allow the theme to be changed at runtime, and the new styles will be used by |
When you say |
I've checked in a fix for menu styles (7250316). Let me know if it works for you! I'll look at toolbars now. (@Camuvingian yes, sorry - I renamed it in my version because it's setting the style, not the container style.) |
That's quality stuff. Cheers, I will implement and feedback accordingly... I just wish i could be of more help with this stuff, but I am fairly new to this and it is somewhat ahead of me. |
No problem, it's pretty confusing for me too :-) WPF doesn't make it easy to have a style |
Works for me - brilliant! |
I've checked in a fix for ToolBar styles too. Please could you attach a screenshot of what the StatusBar should look like? Because I've got a test app with MahApps Metro and a StatusBar, and it looks exactly like the default WPF styling to me? |
@tgjones, when talking about the "markup extension that'll fetch resources from current app resource dictionary" I was referring to something similar to DynamicStyleExtension. Didn't know you already have it. Anyway, the SO solution is even better! By the way, since we're talking about theming here, I wanted to share another idea. Looking at Gemini.Metro module I think that it should be a theme actually, i.e. it should be able to provide a resource dictionary with all it's nice stuff, like current Gemini themes, and it should also be able to hook into Caliburn.Micro WindowManager to provide MetroWindow instances instead of normal windows. So I suggest to make themes a little smarter, i.e. it should be some MEF exported interface with a name and may be some other useful properties and an ability to integrate into the app as deep as they need to. This way it'll be at least possible to gather all available themes and display a combo box in options dialog. What do you think. |
@Camuvingian Sorry for the silly question, but are you sure you don't have any custom styles on that |
@tgjones Hi Tim, thanks for your reply. You are right, I have styled it. Apologies... Issue now completely sorted. Thanks again for your time and help here, it is most appreciated. |
Ah, that explains it! You're welcome. |
@tgjones, awesome! Would be interesting to implement it, so I might get my hands on it some day. |
All, I am having difficulty attempting to style the ToolBar and StatusBar using MahApps metro. There is an example of how to do this for the main window, but I can seem to apply the same principles to skin the Tool/Status bars. Can anyone point me in the right direction here please?
The text was updated successfully, but these errors were encountered: