Creating a Hyperlink to a different TabItem in WPF - c#

I have a WPF application with multiple TabItems within a TabControl. In one of the TabItems, I want to have a Hyperlink that when clicked, changes the view from the current TabItem, to one of the other TabItems.
I've looked into the NavigateURI property of Hyperlink but I haven't found a way to set that to be a separate tab in the same window. Any thoughts on how to do this?

Just make a button, style it like a hyperlink, and change the tab control tabindex on the click of the button.

Related

select buttons orderly in userControl by press Tab key

I have a UserControl with some buttons in it (btnNew, btnCancel, btnEdit).
I used this UserControl in another project. When I press the tab key in this project, the selection button doesn't change regular!
For example, I want that if the user presses the Tab key, first the btnNew button is selected, then the btnEdit button, and finally the btnCancel button.
But in this project, when pressing the Tab key, the btnCancel button is selected first.
I want to manage the tab order of the buttons myself, and not use the default. How can I do this?
Thanks...
To set the order of how the buttons will be selected on tab press use the property
TabIndex
it defines the order the tabs will be selected. So set the tab index like the following
btnNew.TabIndex = 0;//selected first
btnCancel.TabIndex = 1;//the second
btnEdit.TabIndex = 2;//the last one
When the form designer is open go to View > Tab Order this will allow you to set the tab order in a very simple and easy way.
Refer this:http://msdn.microsoft.com/en-us/library/bd16a8cw(v=vs.90).aspx
I don't have much knowledge on Windows Forms, As I know there will be a TabIndex property for each control.
You can set your order using that.
Menu View-> TabOrder
or
manually set TabIndex for each control.
To set the tab order of a control
On the View menu, click Tab Order. This activates the tab-order selection mode on the form. A number (representing the TabIndex
property) appears in the upper-left corner of each control.
Click the controls sequentially to establish the tab order you want.
When you have finished, click Tab Order on the View menu again to leave tab order mode.
Quoted from here.
You could also change the TabIndex property of each of the controls individually in the Properties pane. Or change it programatically like so btnNew.TabIndex = 0;.

Manually opening a ListPicker

I have a ListPicker (from Telerik's Rad Controls suite) in PopUp Mode (with around 200 elements) with its visibility set to Collapsed. I want to open when it when I press a button, instead of when I press the control itself.
Basically I'm asking if there's any way of programatically opening a UI element in Windows Phone (something like Control.Open() in the code behind).
The context for my question is the following:
as you know, the selected item of a list picker is displayed in the page containing the control.
users can click on this item to activate the control.
I want to display only one of the properties in the page containing the control (for example MyObject.Name instead of the entire MyObject), but I can't do this because the SelectedItem and ItemsSource need to be of the same type.
I'm thinking of styling a button to look identical to the ListPicker's selected item.
I need to open the ListPicker programatically when I click on the button, I'll bind the button's text to MyObject.Name
Alternatively, I could just do a data template for the way the list picker is displayed, but I'm not convinced it's possible.
Found the answer. It seems Telerik's List Picker allows you to set both an ItemTemplate for displaying items in the actual page, and a PopupItemTemplate for displaying items when the list is expanded. Both are Data Templates, so you can use Binding for values.

How to mange a listbox inside a tab control

This is the first time I'm trying to build something with a tab control.
At first I made a small application in .NET 4 C#, which had a listbox as a stand alone at its main window and now I want to add a tab control and move the listbox into one of the tabs and a listview into the other tab so I can also present Icons.
My problems I'm facing are as follows:
1) I'm now adding the listbox dynamically to the tab control like this:
private ListBox listBoxMember = new ListBox();
public Form1()
{
listBoxMember.Size = tab1.Size;
tab1.Controls.Add(listBoxMember);
}
When starting the application, it seems like the listbox doesn't fit itself inside the entire tab and I can see it's borders inside the tab.. How can I fir the listbox completely into the tab so it would seem to the user that the tab itself is like a listbox?
2) Before my change I made a context menu which was activated with the listbox's mouse down event upon right clicking the mouse. Now after adding the listbox inside the tab, the menu won't open when the mouse is clicked. How can I use the context menu I made and use it the same way as I did when the listbox was a stand alone control?
To fill the tab with your ListBox, use the Fill property.
listBoxMember.Dock = DockStyle.Fill;
Also since you are now creating the ListBox dynamically you'll need to set the ContextMenu dynamically as well.
listBoxMember.ContextMenu = myContextMenu;
Also be sure to give the listBoxMember a name so you can find it in the tab1.Controls collection.
listBoxMember.Name = "listBoxMember";
tab1.Controls["listBoxMember"];

Keep Label on top of TabControl .NET

I have a label that I need to stay on top of my TabControl as I switch from tab to tab. I have tried calling the Label's BrintToFront method in the SelectedIndexChanged Event of the Tab Control but this has no effect. I also simply tried right clicking my label in design view and selecting "Bring to Front" but again, this had no effect.
When I switch to my second tab it drops behind the TabControl however, when I go back to my first tab it is in front again.
I placed the label itself on the Form rather than on the TabControl.
I am working in C#. Any ideas would be greatly appreciated. Thanks.
You should make sure that your label is not located inside a specific tab. To verify this you need to look at the nesting inside the 'document outline' (ctl+alt+T)
If it is I recommend;
dragging it just outside the tab control (you can also use the document outline).
then 'bring it to the front'.
and then use the arrow keys, or location property, to move it back into position.

New menu on button click

In XAML, is it possible to display a new "screen" when a button has been clicked?
Like for example, in Android apps, you click an option from the main menu and normally a new screen is displayed with different options.
I would like to to do this, I don't want new windows appearing, context menus is not quite what I want either.
Yes. Use TabControl populated with TabItems to switch "frames". You can add as many tabs as you like at design-time.
Then at run-time just change SelectedItem or SelectedIndex property of the tab control to redirect your user to the right tab.

Categories

Resources