What to use as the container with ribbon control? - c#

I'm writing a data-entry software with lots of pages. For example one page for entering team data and another page for entering match data. I want to use the new fancy Microsoft ribbon control to organize different pages and categories.
The problem is I'm new to WPF and I don't know what should I use for:
a. The container of pages (should I create a usercontrol for each page?)
b. The container on the main page where ribbon is placed. (By clicking each ribbon button an specific page should be opened on the main window.)
What would you do?

You could use a DockPanel for the main layout, a TabControl docked to the top for the ribbon, and a ContentControl filling the rest of your application. When a button gets clicked in the TabControl, set the ContentTemplate of the ContentControl.

if you are using the actual RibbonControl from Microsoft there is a RibbonWindow that is used to host the ribbon.
http://blogs.msdn.com/b/jaimer/archive/2010/08/04/wpf-ribbon-has-been-released.aspx?wa=wsignin1.0

Related

(WPF) Popup with a TabItem Layout

I currently have an application that uses a ToggleButton/Popup feature and it all works as expected, but I wanted to see if there's a way (either through control templates or custom controls) that allows the toggle button to be included as part of the popup window.
The effect I'm going for is similar to the standard TabControl/TabItem layout but instead the ToggleButton would replace the header of the TabItem and the Popup would serve as it's content.
In the end, I want to have the Popup window display to the immediate right side of the ToggleButton and have one continuous border that wraps around the outside edges of the ToggleButton and the outside edges of the Popup window with no border inbetween. The final appearance would show no separation between the two controls, and the user would perceive the ToggleButton and the Popup as a single control object.
I was thinking it might be possible to edit a template of a standard TabItem and have it's content property display as a popup, but haven't tried it yet.
Let me know if you think this is the way to go or if there's any other potential solutions. Thanks.
Almost everything in WPF can be done in multiple ways. The same is true with your goal.
If you plan on reusing this control in multiple places, I would suggest building it as a custom control. I build custom controls and UI libraries for a living, so I am a bit biased.
I would build a custom control that inherits from HeaderedContentControl. The Header property is the content of your ToggleButton, and the Content property would be the content of your Popup. Since you own the ControlTemplate and code, you can make it look and function exactly how you need it to with no compromises.

How do I create a Tab Control with no Tab Header in Windows form?

I have created a Windows form using a Tab Control, but it has a header with it. I want to hide it. I am not able to do it using any properties of the Tab Control. Is there any property defined for hiding the tab header for the Tab Control without going through the code?
Use following code to hide the tabs or set these properties in design.
tabControl.Appearance = TabAppearance.FlatButtons;
tabControl.ItemSize = new Size(0, 1);
tabControl.SizeMode = TabSizeMode.Fixed;
You want the tab panels without the feature allowing a user to switch between them, so I suppose you want to create few separate sets of controls to be shown to the user one at a time. You can achieve this in several ways (you can choose one of them if you find it appropriate in your case):
Use several Panel controls instead of several tabs in the TabControl, however, it would be hard to work in the designer, because all the controls would be visible
Use different Forms instead of tabs to keep the layout parts separated. It can be ok, but you may not want to use multiple Forms, so it depends on a specific case.
and finally, the suggested solution:
Encapsulate each set of controls in a UserControl. This allows you to keep each layout separately, so you can easily design each of them without the other controls getting in the way ;). The the code handling each of the layouts would also be separated. Then just drag those controls in the Form and use set their visibilities appropriately to show the one you want.
If none of those suggestions work for you, let me know, so I can look for other possible solutions.
It's more easy as you think, you just drag the panel's window upper, so will be outside of the form.
Use DrawMode: OwnerDrawFixed will hide TabPage header text DrawMode : OwnerDrawFixed
Another way to achieve the same (or similar) is: You can remove tabs from TabControl.TabPages collection and then add the tab you want to show.
During the Form initialization I remove tabs (so into the designer I can easily manage them) and in some control event (as button click) I show the tab the user has to see.
Something like that:
// During form load:
ctrTab.TabPages.Clear();
// ......
// During button click or some other event:
if(rbSend.Checked)
ctrTab.TabPages.Add(pgSend);
else
ctrTab.TabPages.Add(pgReceive);
In this way the user can still see the header tab but just as title of controls group, he can't change/switch the current active tab.

Repeat a user control as user clicks next?

I have a user control that consists of some textboxes and checkboxes. Once the user is finished filling the first one, they should be able to add one more form by clicking an "add another record" link button.
How can I repeat this usercontrol as the user clicks?
I am supposed to use C# only.
So, we are talking of UserControl where your fields are located (I mean, that this is a one class inherited from UserControl or Control. )
There are a lot of ways to do it. But, I think, to be mode 'code concise' is to use FlowLayoutPanel
a) Create this panel. (through visual designer i.e.)
b) When user clicks, create your control
c) add your control to layout panel.
var myControl = new MyControlWithForm();
flowLayoutPanel1.Controls.Add(myControl);
One could use flowLayoutPanel1.Controls array to process all filled forms afterwards.

How to create panel like windows in WinForms

Please See this:
http://img405.imageshack.us/img405/2008/rolloversummaryschedule.jpg
How can i create a window that holds Patient data in it? The 2 records that you see is in List View. I would then using ContextMenuStrip for text "View Details". When View Details is clicked i need to show the context. For web development this could be done via Javascript,div and panels. How that should be WinForms?
Please Help.
Thanks!
How about:
Make a form, formMaster, that displays the Schedule records in GridView
Upon double click on a row event, display another form, formDetail, passing on the selected patient id
Upon loading of the formDetail, get the patient record based upon that ID and set the controls accordingly.
Checkout:
Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls
How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls
---EDIT--
You can use the GroupBox, or the Panel control itself. Usually, with WinForms GroupBox is more of a common use.
Grouping Controls with the Windows Forms Panel Control
Grouping Controls with the Windows Forms GroupBox Control
I take it you mean as a popup panel, like you would see using javascript such as overlib (http://www.bosrup.com/web/overlib/) - implementing this behaviour in winforms.
The way I have done this in the past is by having a user control which is an extended panel, and on the mouseenter event of the specific control I have shown the panel at the mouses's x,y coordinates, which are accessible from the event arguments in the handler.
Then on mouseleave you hide the usercontrol.

How can I simulate a tab control?

I want to have buttons that kind of act like tabs - they switch between "pages" of the application. How can I achieve this effect? I'm thinking that I could just put the controls in some kind of container and toggle the visible attribute, but is that plausible?
I am using WinForms.
The reason I don't want to use a tab control is because some of the panels already have tab controls in them..I don't want to create a nested tab hell. I just want some kind of spiffy button based navigation.
You could "attach" button functionality to Panels, then use the panels as the "tabs". You could even create a UserControl that inherently ties them together.
However, a TabControl (for Winforms) already exists that does this. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx
If you're looking for something for ASP.Net 2.0 and above, you could try the following: http://www.codeproject.com/KB/custom-controls/TabControl.aspx
I think the best option is to use this WinForms TabStrip control -- a subclass of ToolStrip where the buttons are drawn as tabs, and you simply treat them as such programmatically by switching which panel is shown in your container as tabs are selected.

Categories

Resources