What I like to have:
A Dashboard which the user can realigned/move/resize a board with Drag&Drop ability.
The easiest solution could be perhabs to use simple dock windows like AvalonDock. But because I don't like floating windows, I must be possible to automatic re-dock the floating window if the user don't dock it.
What I tried:
I found in LayoutContent.Dock the method, which I need to call when the user stops dragging the floating window. I think, after LayoutFloatingWindowControl.FilterMessage -> case Win32Helper.WM_EXITSIZEMOVE: would be the best place. But after this point I found no event to notify me. Do I didn't see the solution? Next problem: How can I get the object of type LayoutContent to call Dock? :/
Can I continue to pursue my idea?
Or did you know other free controls or ideas to realize this?
Thanks
AvalonDock LayoutDocument and LayoutAnchorable (the controls that hold the content) have a property CanFloatset it to false and it will not be able to float and you don't need to dock it.
see the docs: https://github.com/xceedsoftware/wpftoolkit/wiki/AvalonDock
Related
In one of my previous apps I needed to add controls to a flowlayoutpanel in a winforms project dynamically, but I needed them to stop loading once there was no more room in the panel for them to fit.
To achieve this I wrote: https://github.com/LucasMoffitt/WordFiller/blob/master/WordFiller.Controls/WordLayoutPanel.cs
This basically just sets a property to false if an inbound control touches a rectangle I draw at the bottom of the panel.
While trying to replicate this behaviour in WPF I can't find any way in which I can force a WrapPanel to stop taking in controls if it's full.
I've attempted to override the Arrange and Measure methods but they only get called once all the controls have been added. I need to be able to stop the controls from being loaded at all.
Anyone have any ideas?
So I ended up taking in some suggestions and arrived at this:
https://github.com/LucasMoffitt/CustomWrapPanel
basically it's what I was doing to begin with just a little tidier, and has a demo app.
I encourage all contributions if anyone finds a nicer way of doing it!
You could check ActualHeight/AcxtualWidth against DesiredHeight/DesiredWidth. When DesiredHeight becomes larger than ActualHeight - the panel began overlapping.
I have inherited a large MFC application which contains a CComboBox subclass that overrides OnPaint. Currently it does all its drawing by hand (with lines and rectangles), and renders a combo box that looks decidedly Windows 98-style. However, it otherwise works great and provides a lot of useful custom functionality that we rely on, and rewriting the entire control is probably not an option.
I would like to modernize it so that the OnPaint draws in Aero style where available (falling back to the old code when modern theming is unavailable). I've done this with some other custom controls we have, like buttons, and it works great for our purposes. I know there are some tiny behaviors that it won't get right, like gentle highlights on mouse-hover, but that's not a big deal for this app.
I have access to the CVisualStylesXP ckass, so I've already got the infrastructure to make calls like OpenThemeData, GetThemeColor or DrawThemeBackground pretty easily (via LoadLibrary so we don't force Vista as a min-system). Unfortunately, I don't know the proper sequence of calls to get a nice looking combo box with the theme-appropriate border and drop-down button.
Anyone know what to do here?
Honestly, I don't know why they originally tried to override OnPaint. Is there a good reason? I'm thinking that at least 99% of the time you are just going to want to override the drawing of the items in the ComboBox. For that, you can override DrawItem, MeasureItem, and CompareItem in a derived combo box to get the functionality you want. In that case, the OS will draw the non-user content specific to each OS correctly.
I think you best shot without diving in the depth of xp theming and various system metrics is take a look at this project: http://www.codeproject.com/Articles/2584/AdvComboBox-Version-2-1
Check the OnPaint of the CAdvComboBox class - there is a full implementation of the control repainting including xp theme related issues.
Not sure if it's the same situation - but when I faced this problem (in my case with subclassed CButtons), solving it only required changing the control declaration to a pointer and creating the control dynamically.
Let's assume that your subclassed control is called CComboBoxExt.
Where you had
CComboBoxExt m_cComboBoxExt;
You'll now have
CComboBoxExt* m_pcComboBoxExt;
And on the OnInitDialog of the window where the control is placed, you create it using
m_pcComboBoxExt = new CComboBoxExt();
m_pcComboBoxExt->Create(...)
Since this is now a pointer, don't forget to call DestroyWindow() and delete the pointer on termination.
This solved my particular problem - if your control is declared in the same way, consider giving it a try.
i want to implement a UI look like IE9 or chrome.
i like the dockable tab,it can be dragged out into a new window.
and the window can also be put into as a tab.
is anyone can give me an idea how to implement it, or a library,or an example?
thank you .
AvalonDock is very good, but not quite like I wanted.
There is no dock control that comes out of the box in WPF (which is a damn shame). You can have a look at Sofa Docking, which is an open-source docking library based on AvalonDock.
I'm using DevExpress' docking control (not free). It's not perfect, but their customer support is one of the best out there, and that's a very big thing to me. I found it very hard to find any resources and answers regarding AvalonDock and SofaDock.
You could look at the Infragistics xamDockManager:
http://www.infragistics.com/dotnet/netadvantage/wpf/xamdockmanager.aspx#Overview
If you do this, you would use a DocumentContentHost:
http://help.infragistics.com/NetAdvantage/WPF/Current/CLR4.0/?page=xamDockManager_Add_Panes_to_the_DocumentContentHost_Object.html
Then you would want to disable docking of the ContentPanes on the right, left, top and bottom and there is a boolean property that can be set to control this like AllowDockingLeft:
http://help.infragistics.com/NetAdvantage/WPF/Current/CLR4.0/?page=InfragisticsWPF4.DockManager.v11.2~Infragistics.Windows.DockManager.ContentPane~AllowDockingLeft.html
Shell
{
List<Content> Contents
}
Drag: use PopUp/adorn/visualbrush to create a content thumbnail.
Drop: if out of the parent shell, creat a new shell, and add the
drag-content to the Contents List.remove it from origin parent
shell.
Is there a free implementation of the text box in Blend's property grid that allows you to change the number by clicking and dragging? Or perhaps another way to ask is what kind of control called so I can google it?
just try this
http://www.codeproject.com/KB/WPF/MicrosoftBlendStyleTextBo.aspx
It's called a numeric UpDown control. (Terrible name, I know).
MS has a sample implementation for WPF, although I think you'll have to provide the draggable part yourself.
Is there a way to directly get the Window object a control is on?
Assuming the Control is directly below the Window, you can call GetParent on the LogicalTreeHelper.
You may, of course, need to Use the LogicalTreeHelper to traverse the tree if the Control is not a direct descendant.
Most likely you are on the applications active window in the moment you interact with the control.
So in that case, this other post on stackoverflow could be helpful too:
stackoverflow: get active window(s) in wpf
A bit late, but the following works pretty fine for me.
var ownerWindow = Window.GetWindow(yourControl);