WPF search windows - like tabPages in tab control - wpf

I have idea to implement my wpf windows like TabPages in tab control. It is possible to do that dynamically in c# code.
In Example i have Menu in main window. Some Menu items calls search type windows. Is it possible to do such a thing in C# code (SomeMenuItem_Click): this code adds new tab in tabControl of main window.
If there are no search windows called -there is no tab's shown, if there are many search windows called - there are many tab's.
So how do I code this?
And whats the technique with the windows? I suppose that my search type windows must be implemented like some UserControls. I think its no a good idea to implement that like simple wpf windows. I have tried to do that by using Marlon grech "Blend like UIs using DOCKY", find at:
http://marlongrech.wordpress.com/2008/01/29/create-blend-like-uis-using-docky/
But I failed, dont find the way how to add controlls in code dynamically, not in xaml.
I would appreciate code examples to illustrate how to achieve this.

Is it possible to do such a thing in C# code (SomeMenuItem_Click): this code adds new tab in tabControl of main window.
Yes. The basic pattern is:
TabItem newItem = new TabItem();
tabControl.Items.Add(newItem);
You'll obviously need to set the relevant properties of your tab item (such as the Header and Style) but that should get you started.
You'll then need to create any controls you want to show and add them to the tab item itself (or more correctly - a container within the tab item).

Related

vb.net - Can I load a wpf form into a canvas/grid control?

I trying to see if its possible to load a form into a canvas or grid control in wpf with vb.net.
I'm not very familiar with WPF at all, usually working with Winforms more than anything else, however I need to take advantage of the far superior transparancy options offered by WPF for this current project, so need to see if I can crack this.
In Winforms, I'd normally have a panel (call it contentpanel or mainpanel etc) and then whenever I needed to I could easily load another form into that panel dynamically and keep everything neat and tidy in one form when presented to the user, so something like...
dim newforminstance as form1
newforminstance.toplevel = true
newforminstance.topmost = false
contentpanel.controls.add(newforminstance)
newforminstance.show
That works a treat in Winforms; Is there a similar way to achieve this functionality in WPF?
Thanks in advance.

Make Custom WinForms Control Work with Narrator (Accessibility)

I have a custom list control derived from Control class.
I need to make it accessible to people with disabilities through MSAA (Microsoft Active Accessibility).
So far I understand that I need to create class that inherits from ControlAccessibleObject and then return its instance in Control.CreateAccessibilityInstance method override.
The problem is that I have implemented this and it seems not work with Windows Narrator tool.
For example, when I click on an item in standard ListView, the Narrator speaks out the selected item text.
But when I click on item in my control, nothing happens (although the item text is requested in my ControlAccessibleObject implementation)
I thought I need to implement IAccessible as well, but I looked on .NET refrence source code and the ListView does not implement this interface. I thought maybe this is implemented in the wrapped Win32 control, so I took a look on similar control - DataGridView - but this does not implement IAccessible as well.
DataGridView have accessibility support, but although I copied all the important code of DataGridViewAccessibleObject, it still does not work in my control.
Do anyone have more experience with custom control accessibility in WinForms?
Okay, I found it: The Control.AccessibilityNotifyClients method does the magic. One have to override this method in a derived control.
However, to make screen readers speak the text, I had to call:
AccessibilityNotifyClients(AccessibleEvents.Focus, index);
AccessibilityNotifyClients(AccessibleEvents.Selection, index);
Here the index is an index of newly selected item.
I found this code in the .NET reference source of CheckedListBox. When I used Focus or Selection event solely, the screen reader have not reacted. The spoken text also depend on the AccessibleObject state that corresponds to a newly selected item.

How to Create a Dockable Tab like IE9 or chrome

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.

WinForms "mini-windows"

I need to create some mini-windows, like the ones shown in the image bellow, in my winform main form.
It would be nice if they could be draggable, resizable, and, mainly, closable.
How can I approach this design? Has anybody already seen some control (with code available) implementing something similar?
alt text http://img716.imageshack.us/img716/5765/imagea.png
A normal Form works fine for this. Set its FormBorderStyle to either FixedToolWindow or SizableToolWindow as desired.
If you want to keep your floating windows inside your main window, use MDI (Multiple Document Interface). Here is a tutorial (Google can find you many more).
Have you tried just setting the FormBorderStyle property to SizeableToolWindow?
Is that what you're after?
You can create them as resizable and draggable custom controls.
You could use my example at:
http://hourlyapps.blogspot.com/2008/07/resizable-and-movable-controls-c-net.html

WPF windows organization techniques

Im developing some wpf app. Basically i have two types of windows: search windows and insert/edit windows. When i developed win forms apps, i used a trick, called MdiParent. In that way i had ability to put my caled search type windows in a "stack". In orher words if i called 5 different search windows from meniu, they apeared in a component like tab control, one after other.By clicking on that tabs, i could see search results of clicked tab window. The trick as i said was MdiParent technique, like:
private ProductDiscount frmProductDiscount = null;
private void ProductDiscountToolStripMenuItem_Click(object sender, EventArgs e)
{
if ((frmProductDiscount == null) || (!frmProductDiscount.Visible))
{
frmProductDiscount = new ProductDiscount();
frmProductDiscount.MdiParent = this;
frmProductDiscount.Show();
}
else
{
frmProductDiscount.Activate();
}
}
So does anyone can me suggest a good way to implement such a window organization technique in WPF and put some links or examples..?That would be a big help for me.
There is no equivalent of Form.MDIParent in WPF and MDI does not support the idea of an MDI layout. You can set a Windows Owner to another window. This will minimise the child when the parent is minimised.
For an example of MDI style functionality have a look at this thread link text
where Marlon Grech has written something similar to what I believe you are trying to do.
We developped similar application, as WPF doesnt have any default MDI framework but since its completely customizable, what you can do is, you can create User Controls of your "Window" instead of Window type and you can use inside a TabControl and you can customize TabControl to have close buttons etc. Windows in Tabs as they appear in Visual Studio, IE etc, they work good for this type of scenario when you dont want to block user input on modal dialog.

Resources