How to show same control in different pivot item? - c#

Is this possible to show same control in every pivot item.
So I think my options are
1.Change the pivot header but not changing the pivot actually.
2.Add the control as a child control of a grid in another pivot item.[which i think not possible]
3.Just ctrl+c and ctrl+v the design with different names of the control[i don't want to do this].
Is there any other way? Option 1 or option 2 is possible? If yes how?
Please Help.

In your case what makes more sense is to create a UserControl.
I suggest that you create a UserControl from the Grid. It is easy to do in Blend. Open your project in Blend, expand the page contents in the Objects and Timeline panel, right-click on the Grid and select Make into UserControl. Blend will create a UserControl class that you can reuse in each PivotItem.
Taken from MSDN Forums
//Now you should be able to do something like this.
MySecondPivotItem.Content = new MyUserControl()
And that's all. Also you can create the PivotItem on the flight and add it to the Pivot, like this: (Assuming that pivotMain is your Pivot)
pivotMain.Items.Add(MySecondPivotItem);
Hope this helps

Related

How to achieve Oculus UI in .Net WPF

I am trying to achieve this look&feel in WPF.
It basically acts like a TabControl, with the tabs on the left (vertically)
The right side of the window completely changes depending on which item you have clicked on the left "nav bar":
Oculus UI
What I did:
I started doing a Custom Control. A grid with two columns, a StackPanel in the left column in which there will be a clickable button/label for every menu entry (vertically of course). A Property MenuEntries which is a List<string>.
How do I get the control to add a "tabpage" (a grid/canvas?) programmatically for every MenuEntry the user adds at design time?
How can I achieve the behavior of the TabControl during design time, i.e. the content on the right side changes as soon as the user clicks an item on the left (in the designer/editor)? (kind of like the TabControl itself?)
Is this the right approach or would you do that completely differently?
Yes, you can use TabControl for that, just set TabStripPlacement="Left", (some more details)
The whole rest: colors, margins etc is set via styles.
Also, to save you a lot of trouble, use MVVM (with some framework for WPF) for that. Set ViewModel collection as ItemsSource for the TabControl.
Then, when you select one of the tabs, the control will display the view for the selected VM.
DO NOT set TabItems in xaml for each tab, this is wrong way to go in the long run.

Multiple UI for a single ListBox in Wp8

I have a listbox in the xaml page.I have created three tabs(Normal text boxes) on the top.If clicked on tab 1 or tab 2,it displays an expander view in the listbox as its item.I want to create a simple listbox for the 3rd tab,i.e, no expander view.Is it possible in wp8?
I not sure that I understand your question, but I think that you could use a Pivot control to achieve the results you want to get.
Using a Pivot, you could get different "tabs" and each tab could have his own controls. Hope this helps

Treeview with changing controls in same window

I am re-designing some GUI items and want to implement something like the following:
As you change options in the TreeView on the left, the controls on the right change according to the option selected.
My question is, what is the best way to implement this? I was thinking of setting the visible property to true / false for each control to it's respective TreeView option selection; however, designing this on the VS GUI editor would be pretty painful as there would be hundreds of controls all over the place and on top of each other.
User controls. Create the blocks you have outlined in red as user controls and add/remove as you select/change node in the treeview.
If you want a "buffer" effect to avoid flicker when removing an existing control, then use a tab control with two pages (without showing the tabs.) Start with showing TAB1 then when selecting a node in the treeview add the correct control to TAB2 and then make TAB2 the active page. And then remove any existing controls from TAB1. And then the other way around when the next node is selected. etc etc.

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.

CustomListbox control, how to make the items have a custom feel to them in C# (winforms)

So i have a listbox, and here is what im trying to acheive:
have the class style adding/selecting/removing sort of like a TreeView
ListBox items have more than one label docked to different sides of the space ( for example, the item would be thicker, and would be big enough for two labels on top of eachother, and then perhaps another off to the side)
when selected/not selected, the items will have a transparentish picture overlay
What I need to know:
Is there a (free/opensrouce) control that this can be easliy accoplish this
If No to 1, how should i begin to create this, (where to start, what to avoid etc)
I ended up using a user control, and created children that draw themselves, and then just included them in my listbox, so i got it working! thanks anyways guys

Categories

Resources