Can't Find Specific Listbox for Windows Phone - windows-phone-7

I am right now looking for a way for a user to open a listbox, choose an option, and the program continues to run, considering the desired option. My best option was to use a listbox I found in the Settings section of the phone.
I don't have a way of explaining this control completely, so I'll use an example. If you go into the Regions & Language section of the phone and then hit Region, you will notice a list pops open. The same listbox is opened when choosing a ringtone. This is exactly what I need for my application. The only problem is, I don't know what it is called. Help!
I included two images

That control is not called a ListBox, Windows Phone calls it the ListPicker. Here's an article explaining how to use it.
The control is included in the Silverlight Toolkit for Windows Phone.
Note that the article is old and a few of the properties for the control have been renamed / made read-only in the latest release of the toolkit.

What you need is the ListPicker from the Windows Phone Toolkit. You'll need to handle changing any settings yourself. This can be done through binding to a property that gets changed or via code that you write.
<toolkit:ListPicker Header="Language" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay}"
FullModeHeader="LANGUAGES" ExpansionMode="FullScreenOnly"
SelectionChanged="ListPicker_SelectionChanged">
<sys:String>English</sys:String>
<sys:String>Spanish</sys:String>
<sys:String>French</sys:String>
</toolkit:ListPicker>
If you need to handle changes:
private void ListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// handle any changes that are needed
}

Related

Xamarin Forms open a view without Navigation

Xamarin Forms navigation examples I see leverage a NavigationPage...
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new HyperTrack2.Login());
}
and then when an event occurs to move to the next page...
async void OnLogin(object sender, EventArgs e)
{
await Navigation.PushAsync(new MapPage());
}
How can one show a view without using the NavigationPage?
Depends on what you consider a view to be.
The process you outlined in your question is the prefered way to navigate using Xamarin pages. Xamarin pages contain one or more controls, or views. Usually some layout views at the root and then they branch out as needed.
The built in navigation mechanism actually utilises the optimal native techniques for navigating inside your application and will allow you to use standard gestures and buttons for navigations, display standard toolbars and title views, etc.
I fully recommend that unless you have very specific needs, you keep using the built in navigation mechanism.
Otherwise, your other option for moving through xamarin.forms pages is by just settting the MainPage property of your Application class (called App by default)
You can either access it through Application.Current.MainPage = new MyPage(); or if writing code within the app class, directly by calling MainPage = new MyPage();
Lastly, you specifically mention showing a view and not a page. If you are talking about a single control within a page, you can either bind it's IsVisible property to some value in your ViewModel, or you can give it an x:Name="myControl" (if using XAML) or store a reference to it (if creating UI in code behind) and then do myControl.IsVisible = true/false somewhere in your code behind. This toggles the visibility of a single control, which will then become a part of your page hiearchy.
If you instead wish to display the view as a "popup" over the existing page, without it actually becoming a part of the page, there are some built in simple UI elements you can use, such as action sheet and display alert. These provide simple popup windows that offer a couple of actions or display a message.
For more complex UI, look into Nuget plugin packages, or if you prefer, you can write your own by implementing the functionality on all the target platforms you require.
I suggest looking into Acr User dialogs as it's a wonderful plugin that has served me quite well. It has a much broader set of UI elements you can use, but it still won't let you define any element that you want and display it in a popup, to do that, search for popup plugins for Xamarin.Forms. There are quite a few, but none work perfectly imho.

White/TestStack UI Automation - clicks app button opens a browser, how do I check the url?

I am currently using White/TestStack to test a windows app.
There are scenarios that requires user to click on links to open pages on browser. How do I check the hyperlink is working?
Old question but in case somebody else looking for an answer:
If you check in the White GitHub repository and you browse the UITests and the control tests, you will find the Hyperlink control test. In the sourcecode, you will find several tests according the type of framework used.
The simplest one:
var hyperlink = MainWindow.Get<Hyperlink>("LinkLabel");
hyperlink.Click(10, 10);
Assert.That(hyperlink.HelpText, Is.EqualTo("Hyperlink Clicked"));
The test is based on the used of code-behind for the MainWindow:
private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
{
AutomationProperties.SetHelpText(LinkLabel, "Hyperlink Clicked");
}
XAML code of the hyperlink in the MainWindow
<TextBlock x:Name="LinkLabelContainer">
<Hyperlink x:Name="LinkLabel" Click="Hyperlink_OnClick">Link Text</Hyperlink>
</TextBlock>
So you can used the same method.
TL;DR
You can link the Click() event of your hyperlinks to a method in code behind which update the automation property HelpText of the hyperlink with a specific value for the clicked event.
So in your tests, you will just have to perform the click and then check the automation property value.

Windows Form -- behavior of buttons?

First time I've used the windows form so I'm not very familiar with the interface. But how do I set behaviors when I add buttons? For example, if I want to click "Button 1" and have it open up a new window to enter information in different fields, how is this done?
Thank you.
edit: Sorry, I forgot to include the language. It's in C#, and I'm using MS Visual Studios. I've never really programed in C#.
Another question that just popped up: could I do this Windows Form in other languages such as C++?
Yes the comment above is key but, if your are using the UI designer on a windows form then under the properties tab on the side of visueal studios, you can view 'events'. from here double click the event you want, probably 'onclick'. This will create a method stub with the event handler automatically set up.
Look something like:
public void Button1_OnClick(Object sender, EventArgs e){
// open the other window for input
Form whateverForm = new Form();
whateverForm.show();
}
Hope this helps. Sorry im not sure about any c++
[Edit]
tutorial not great but take a look:
http://www.ehow.com/how_7241167_tutorial-microsoft-visual-studio.html

How to highlight text on focus in windows phone 7?

How do you highlight a the text in a TextBox control in Windows Phone 7? I can't find a property setting on the control.
Is handling OnFocus event in the code-behind the only option?
You can highlight text using TextBox.Select(int start, int length).
There's actually a pretty great attached property that you can use to do this. You can see an original description of the solution of auto selecting text in a textbox and also see a project where I made user of it.

How to show XAML inside a Tab Control in Silverlight 4

I am wondering how to display a XAML page within a tab control that is part of another XAML page. Or, for that matter, if this is even possible. I want to be able to click a button on page1 and be able to view the page2 from within a tab control that is on page1.
Would this be something to be handled within a Frame control? Or something different? Or is there a better approach to this altogether?
I am programming in Silverlight-4.0, C#-4.0 from within Visual Studio 2010.
You could use the navigation framework, but that isn't really what you're asking. You want to know how to put the contents of one file into a tab, while the contents of another file are in the other tab.
A page in silverlight is simply a user control. You can put a usercontrol into the tab just like you would any other control. In order to use a local usercontrol in another xaml file, you'll need to do the following:
Add this to the root element of the page containing the tabs:
xmlns:local="clr-reference.MyApplicationNamespace"
Then you can add this to add the control into the tab:
<local:usercontrolname name="mycontrol" someproperty="value" />
You can check the Silverlight Navgition Framework You can show "frames" inside your control. It also support deep linking, which is the killer feature here..
This is a very good intro - by Tim Heuer

Resources