I have tried to use this Tool and I don't understand its purpose. In previous versions, it created a UserControl out of the selected controls. Now it creates a ButtonStyle for what I have seen.
How can I use this tool?
The old Blend has two options, Make Into UserControl and Make Into Control.
The Make Into UserControl wraps whatever you selected into a UserControl while the Make Into Control has always been turning whatever you selected into a Custom Control.
A Custom Control generally has a default style, and that's why you see that predefined ButtonStyle1 on the popup. A Button is a Custom Control, and that's why you can customize its look and feel by changing its style.
I'd strongly recommend you to have a read on how to create a Custom Control.
Related
Lets say I have a search box, which is a stack panel containing a TextBox and a Button with an icon. For easier re-usability I would like to extract said search box into a separate file.
What would I use to wrap the searchbox? I have all the functionality as attached behaviors, so I don't need any code behind.
ItemsControl doesn't fit, because I don't want to display items, ContentControl does not, because I have no content...
Could you give me hints how to fragmentalize in XAML? The only examples I find are for ResourceDictionarys, but not everything is a Style.
User Control
User Controls provide a way to collect and combine different built-in controls together and package them into re-usable XAML. User controls are used in following scenarios:
If the control consists of existing controls, i.e., you can create a single control of multiple, already existing controls.
If the control doesn't need support for theming. User Controls do not support complex customization, control templates, and difficult to style.
If a developer prefers to write controls using the code-behind model where a view and then a direct code behind for event handlers.
You won't be sharing your control across applications.
Custom Controls
A custom control is a class which offers its own style and template which are normally defined in generic.xaml. Custom controls are used in the following scenarios:
If the control doesn't exist and you have to create it from scratch.
If you want to extend or add functionality to a preexisting control by adding an extra property or an extra functionality to fit your specific scenario.
If your controls need to support theming and styling.
If you want to share your control across applications.
source (including example and more)
What would I use to wrap the searchbox?
A UserControl: https://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol(v=vs.110).aspx
Creating a UserControl is a suitable model if you want to build your custom control by adding existing elements like for example StackPanels and TextBoxes to it.
We have a designer that did a whole concept of GUI for our next WPF application.
If we are able to provide him a "user friendly" way to edit styles, he would have done it by itself.
He only has to edit colors, and small things like Margin, default fonts, ...
Naturally, I tought that Blend would be the solution, but I admit I'm struggling:
Blend allow us to edit the template, but we don't really want to change the whole template, just some color around. We made a small dummy app that has all the controls required to be themed, we edit template in a dedicated theme file, but I can't find how to have the same template applied to every control(e.g. button) in our application
We use DevExpress as library, and it appears that most of their component are composed of a lot of subcomponent(for which I cannot just right-click then edit template). Plus it seems that the devExpress theme have the priority over the templates changes(tested by changing background colors by example)
As a pure developer I would create a "style" that would be applied on all controls of a specific type in our application, but I can't see how to create and edit them in blend?
What approach would you take?
You want to use DevExpress Theme Editor. It will allow you to edit all used DevExpress themes in your application. It has a friendly UI which should be usable by your designer.
Another approach is probably not so friendly for your designer but you can also manually override DevExpress themes with your extended ones (require XAML). I am not sure about the controls but that way you can for sure modify brushes.
I am deriving a custom control from StackPanel (or just using the usual UserControl class). This control should be focusable within the application by either tabbing or clicking the control. When focus occurs, based on other criterion the control will expand and show certain elements. The control will also choose a default child control to focus on.
The issue I have is that I can find no way to focus on a UserControl. The Got/LostFocus events don't fire when I click on the control.
I am aware of the Focusable property, but it doesn't seem to be available on any of the client dlls for Silverlight (using v4 of SDK)
What I would really like is some advice on how best achieve the functionality of a panel I can tab to, as the UI design I have in mind hangs on this.
I guess the control you are looking for, is an Accordion or Expander control.
Here, you will find steps to use the Accordion control. Hope that helps.
Must every control in the Visual Studio WinForms toolbox descend from Control?
Does Visual Studio support window-less controls?
Every control you add to the Toolbox in Visual Studio:
must1 descend from Control, which is a wrapper around a windowed control.
Unfortunately, Windowed controls are very "heavy"; having a lot of them, especially nested, causes performance in WinForms to suffer.
In the past i've dealt with the problem by creating aggregate custom controls. The custom control internally contains other window-less controls:
an image (windowless version of a PictureBox)
title label (windowless version of a Label)
subtitle label (windowless version of a Label)
border (windowless version of a Panel)
These are useful to mitigate performance problems in WinForms, but they're stuck inside code.
i would like to do what other development environments allow, is a version of Control that doesn't create a Windows window. i would like the ability for the Visual Studio toolbox to accept **window-less* controls.
i know that if i really wanted window-less controls: i should switch to WPF. But that's overkill.
Does Visual Studio WinForms support window-less controls?
1 or not
Yes and No.
First, check out this article from the venerable Raymond Chen: http://blogs.msdn.com/b/oldnewthing/archive/2005/02/11/371042.aspx
Yes. You are welcome to create "controls" that do not derive from Control. I have created several windowless controls in my application that natively support clicking, layering, etc., I draw them to an offscreen buffer, and then paint them directly on some parent Form or Control (such as a PictureBox). This is straightforward to do but not simple, as you will need to manage everything yourself in code.
No. Any windowless controls will not be supported in the Windows Forms designer for any of the Control-derived controls designers (such as placing them on a Panel or Form) so you won't have drag-and-drop form design.
As Hans has pointed out, the ToolStrip and MenuStrip (a windowless control) are such examples. Notice that when you create a new MenuStrip on a Form, the MenuStrip is placed in the Component tray underneath the form. The MenuStrip has a custom set of Designer classes associated with it to support the custom painting and "Type Here" functionality, as well as the dialog boxes to add and remove menu items. Note that the "child" windowless controls, such as the ToolStripButton, are not available in the ToolBox for drag-and-drop support directly onto the form - only the custom designer knows about it. The custom designer for the MenuStrip also supports selecting the child windowless controls so that you can edit the properties of each item in the Properties window.
I can't imagine this is suitable for your situation (unless you are creating some controls for resale), but if you are very determined, you can create designer support in much the same way for your set of windowless controls:
Create a class that derives from Component that will be used to manage your Windowless controls. For example, you could call this class WindowlessWidgetManager. After you compile, this control will be in your toolbox. The WindowlessWidgetManager can contain a collection of your windowless controls, and provide painting and other UI support for a canvas such as a Form or PictureBox.
Create a designer class that derives from ComponentDesigner that supports things such adding and removing your custom controls at design time. For more information, see http://msdn.microsoft.com/en-us/library/system.componentmodel.design.componentdesigner(v=VS.90).aspx
This is a very lengthy process with a number of caveats, but if that is what you wish to achieve, the functionality is there.
I am trying to create a custom wpf control, I'm wondering how I can add some design-time features. I've googled and can't seem to get to my goal.
So here's my simple question, how can I add an entry to the design-time context menu for my WPF usercontrol? The context menu by default has entries View Code,View XAML, etc.
You probably want to check out the WPF Designer Extensibility documentation. Specifically it sounds like you want to create a custom MenuAction.
This will help you get the context menu you require, although this applies to datagrid's still applicable;
WPF DataGrid Design-time Walkthrough