Error When using Microsoft.DwayneNeed to solve WPF airspace isssue - c#

I have a wpf app,which used winform control on the mainwindow.Of course ,this winform control stays ontop when a show a modal border. After that,I found Microsoft.DwayneNeed way to solve this problem.It works. But there's a new problem shows up. Let me describle my situation:
In the MainWindow,I have a Grid,which has three columns.The control in first column is a normal wpf control.The second column contains a Gridsplitter.And the third columns is where the winform control lays in.
Before I use AirspaceDecorator(From Microsoft.DwayneNeed) as container of winform control,except the winform control always stays on topmost,every thing is ok, and GridSplitter works well.
After I use AirspaceDecorator as winform control's container, winform control doesn't stay topmost.It's good,it's what I want. But surprisingly, GridSplitter doesn't work any more:
1.Generayly,I can't drag GridSplitter --- it should be drag horizontally as designed.
2.On occassionly,GridSplitter will be dragged to the end of the left or the right edge of window .At this curcirmstance,the winform control occpies all the window,or zero.
I tried some ways,such as AirspaceFixer,using WinformHost to host dialoge border,etc. But none of these methods works.
Thanks !

After some testing,I resolved this problem.The answer is to use AirspaceFixer correctly.
Before you call something show on winform control that wrapped by AirspaceFixer,you should set FixAirspace to true,and after you hide upper wpf control,you should set FixAreaSpace property to false. Just like it's demos shows up.

Related

TopToolStripPanel won't show in UserControl

I'm currently trying to create an image previewer in my program, which I'm doing by creating a UserControl. All seems to be working great, except that I now would like to move some of my buttons to the top of the UserControl.
I have done this by creating a ToolStrip and adding two buttons and a combobox. My problem is, that the new ToolStrip (toolStrip1 - see Document Outline pic.) won't show when I run my program. I have tried settings toolStrip1.visible = true and using the .BringToFront() method, but none of these options seems to work.
Can someone help me solve this irritating problem?
P.S. toolStrip2 is showing just fine in BottomToolStripPanel.
Picture 1: My Document Outline
Picture 2: My Image Previewer Design. The top bar is toolStrip1 which I'm currently not able to see when I run my program.
I've quickly duplicated your layout, and it worked without a problem here.
Do you not by any chance set the "TopToolStripPanelVisible" property on the "toolStripContainer" to 'False' programatically?

Winform User Control size switch back to initial size after localized

this is my first thread on this great website for programming :)
I have a problem with my UC. I'm currently developing an extended version of DataGridView, which added some functionality like paging support.
Here is the picture of the UC inside a form, after I make it bigger than the initial size:
And finally, I change the form's language to Indonesian. And then the designer suddenly repaint my UC. The size of the container of my UC is OK, means the designer remembers that I resized my UC before. But unfortunately the controls inside the UC's container gets switched back to their initial size, leave some blank spaces inside. This behaviour only happen in design time. The UC is fine in runtime mode, its size works well.
How could this happen guys? Although it's fine in runtime, but it's ugly in design time.
Sorry for my English, greeting from Indonesian :)
Thanks.
===SOLUTION===
After play a bit, finally I've found the solution. Before I place the controls inside to the container, I must first add a Panel to the container, set it to transparent, and set its Dock property to Fill. Then followed by DataGridView and BindingNavigator to the rest. Build and it works like a charm!
It seems that the Panel resolves the problem :)
Cheers
Maybe it will help to change the order of the factors. First change the Form language to Indonesian. Then save your project and close it. Open it again and check if it still on Indonesian then place the DataGridView control on the form and re-size it.

WPF validation showing from different layers

I am trying to build a MDI UI in WPF.
I have tried MdiContainer and WPFMDI but I have an issue in both cases. If I have a usercontrol with validation showing red borders, and another user control is shown on top of it, the red border from behind is shown.
I have shown the behavior at https://wpfmdi.codeplex.com/workitem/13413 and https://mdicontainer.codeplex.com/discussions/644330
Since the same issue happen in both library, is there something WPF-related?
Any idea on how to fix it?
Since it seems a complex task, any ideas on how to build MDI UI using WPF that would work with validation?
I finally found the issue and it is not related to the WPFMDI component I am using.
The solution is to wrap your StackPanel or Grid containing the controls being validated into an AdornerDecorator.
The solution was found at https://www.devexpress.com/Support/Center/Question/Details/B195328

User control keeps stretching once dropped on form

This may be a winforms newb mistake, but I've created a user control that has one component on it - a Telerik dropdownlist control. When I initially drop it on a form it looks correct. However, as soon as I run the form the control stretches off the form.
The dropdownlist on the user control has its anchor property set to top/left/right/bottom.
Before:
After:
What the heck am I doing wrong here?
EDIT: a bit more info: If I close the designer and open it back up, it immediately changes sizes. The code itself doesn't appear to cause the problem. In fact, I commented out all of the code (besides the InitializeComponent() call) and I still see the problem. The control itself still works - when I run the form it is populated with the data I'm expecting. It's just stretched.
I can "work around" the issue by setting the width of the dropdownlist about 35 pixels less than the size I actually want it to be, so when it resizes itself it's actually the correct width, but I really shouldn't have to.
You were probably on the right track. It looks as though it is anchoring to something that is way off the page. I would try removing the anchor right for starters to see what effect this has. If that doesn't work, perhaps try different combinations of the anchoring to see what effect it has on the control.
Make sure there are no docking settings enabled, as it would undo any anchoring you have on the control.
Check to see what the dropdownlist control is contained in. You said it was in a usercontrol, but is it within a grid in the UC or anything else like that? Also, ensure that the user control is sized properly (not outside the bounds of the page) -- would cause anchoring problem. Use a background color to test this.
Next, I would check the Maximum/Minimum size of the control (perhaps consider setting one?).
If all else fails, delete the dropdownlist and create a new one and see if you have the same problem. Sometimes the designer side of code gets glitchy and causes problems or you just accidentally change something you didn't mean to.
Finally, last resort, just use a normal drowndownlist ;)

DataGridView cannot be Focused, but one of them can

I've come across the strangest bug pertaining to DataGridViews in Windows Forms.
I have a TabControl, that is supposed to contain a docked DataGridView in each tab page. I thought it would be convenient that the grid is focused upon changing the tab page, so that the user could simply hover the mouse over the grid and start scrolling when he changes the page. So, I just put a grids[tabs.SelectedIndex].Focus() in the event handler for changing the tab page.
However, something really strange happened. In my test application, I have three tab pages. If I try scrolling the grid right after starting the application, it doesn't work; I have to click in the grid first. I was expecting this. However, if I change the tab page, I can't scroll in any of the other grids until I click, except for the first one!
So, if I switch pages to the second page, then back to the first, I can automatically scroll that grid without clicking, but if I then switch to the third, I have to click for the grid to focus.
I had a look at the CanFocus properties of the grids, and it seems that only the first grid has it set to True. They are all created programmatically, and all in the same way. I don't see why they would be different.
Any ideas?
Inactive tab pages have their Visible property set to false. The documentation for CanFocus says:
In order for a control to receive
input focus, the control must have a
handle assigned to it, and the Visible
and Enabled properties must both be
set to true for both the control and
all its parent controls
Well, I solved it. Stupid programming error on my part, I had grids[tabs.TabIndex].Focus() instead of grids[tabs.SelectedIndex].Focus().
Oh well.

Categories

Resources