How to override default WinUI 2.x styles in Blend? - xaml

Previously I had asked where to find the default styles for the WinUI 2.x controls, and was pointed to the appropriate repository in GitHub where those could be found. Thanks! However, what I really want is to be able to override some of the styles. I was expecting that I would be able to do so in Blend, but I have not been able to figure out how to do that.
For example, when I load my project in Blend and then try to edit the templates for the ContentDialog, I am offered the option to apply an existing style, but not to create a new one. I was expecting I could create a copy, which would give me the default styling as a starting point and allow me to make the small modifications I require. Regarding buttons, I was able to edit a copy of the template, but that only gave me access to the ControlTemplate where I want access to the equivalent of DefaultButtonStyle.
It has been a while since I've used Blend, so perhaps I am mis-remembering how the tool works. But in previous versions of our app I was able to generate resources that included the full styling of the controls that I was using, such as buttons and content dialogs. Can I do the same for our current app that uses WinUI 2.x? If so, how? And if not, what are my alternatives? I have considered copying the default templates I am interested in into the resources of my project and making modifications that way, but I am hopeful that there is a better way.
Rich

I am offered the option to apply an existing style, but not to create a new one
This is expected. For example, both the Visual Studio or the Blend for Visual Studio can't directly create a default DropDownButton style of WinUI. You need to manually copy the WinUI style from Github and put the style in your XAML.
For native UWP controls, you could just generate a copy of the style automatically.

Related

VSCode GUI theming: How to slim down pane tabs?

Hi,
Is it possible to make the tabs shorter?
In the theme I'm working in, the way they look by default they are too tall and look out of place.
I already looked into VSCode settings but couldn't find any property associated to their height.
No. As of VS Code 1.19, you cannot customize the height of the tabs using a theme
This type of customization would probably fall under this feature request

UWP custom control template not applied (but only in one project)

I have created a custom version of the default UWP button control template, which simply modifies the color scheme of the disabled state.
In a test project this customization is applied correctly, but in my real project it is ignored (although other custom control templates are applied correctly).
I have searched the project for TargetType="Button", hoping to discover something else that is overriding or interfering with this custom template, but there is nothing unusual; just a few style definitions that are setting properties for specific button instances.
Can anyone suggest why a custom UWP control template would be ignored or how I can debug what's causing this?

Better way to add custom controls to your project

There are groups of customized user-interface components, freely available for VS 2010 Express. They are called "themes". Here you have a video showing how these themes can be added to a VB project:
http://www.youtube.com/watch?v=Ec9GZaPMGqE
I would like to be able to apply a "theme" to my already existing application, but doing so would require me to manually replace all the elements in my form with the newly imported ones. Is there a better way to do this?

How to add a button to the main toolbar in Eclipse programmatically

I've a question. I cannot find the way, how to add buttons to main toolbar programmatically. My problem is, that I've the task to dynamically (based on XML configuration file) build menus and toolbar. I found how to add a menu item programmatically, but not toolbar button.
Tutorials mostly show how to create buttons and menus using plugin descriptor (plugin.xml), but not how to do it programatically. It seems, that it is out of bounds of Eclipse plugin philosophy.
I've just found this:
There might be layout problems with this approach. I also don't
believe the framework will try and re-create your dynamic item except
at random toolbarmanager updates. With Menus they can be updated on an
SWT.Show event, which is why CompoundContributionItem only applies to
Menus.
What shall I do? Can I say Sorry, there is no way to build toolbar dynamically. I can do it just for menus? Collegue says, that it must be possible, but he does neither know how.
The only way to be able to create main toolbar entries programmatically is in an RCP app, where you supply the ActionBarAdvisor for the workbench window. This isn't dynamic, however, just called on window creation.
Another way to do it would be to use org.eclipse.ui.menus and contribute org.eclipse.ui.menus.ExtensionContributionFactory. It also works only on workbench window creation (not really dynamic), but you could read your own XML and provide IContributionItems for the main menu or toolbar.
How dynamic are you trying to be? Most solutions work well on startup/window creation.
PW
Whenever you try to do something programmatically in Eclipse that is normally done through plugin definitions you are walking on thin ice. I've tried it on a few occasions and it rarely ended up being easy or good.
Instead, think of what it is that you only know at runtime and need to be able to change on the fly. Is it the name or icon of the button? That can be changed at runtime.
Take a look at runtime commands, they can be confusing to define properly, but with them you can for example create buttons that are only visible if a condition is active. That condition could be set at runtime.

Editor context Menu - Eclipse-RCP

I have an Eclipse RCP application. I have created an Editor. There are few context menu (default), when I right click on the Editor. I have not created these menus.
Please let me know, How to remove the context menu of the Editor?
It needs different approach by which editor you extends.
Let me know What you extends, than I can answer more efficient one.
In general way:
IWorkbenchParSite#registerContextMenu(...) will be used, So find where calls that, override it. It is not recommend. Because by doing this, Menu Extensions which is contributed for your editor will not work anymore.
If you mean the system menu that appears on editor tabs and view tabs, that menu is provided by the presentation (2.1, Classic, Default, etc). There is no tweak to simply modify it.
The 2 ways to remove it would be:
write your own presentation, using
the
org.eclipse.ui.presentations.StackPresentation
API and matching extension point.
Writing a presentation is a involved
undertaking.
Change the internal classes in the
org.eclipse.ui.workbench plugin
and patch that plugin in your RCP
app.
If you use Text or StyleText you will get the system default menu (cut,copy,paste, maybe something about encoding or input). If you are not going to supply your own menu, simply create an empty SWT Menu and set it:
Menu emptyMenu = new Menu(text);
text.setMenu(emptyMenu);
Eclipse also has a text editing framework, if you need more than a basic text box you should check it out. http://wiki.eclipse.org/The_Official_Eclipse_FAQs#Text_Editors