How can i get the value of a selected comboBox Item on WP7?I tried this code:
string val = MonthBox.SelectedItem.ToString();
textBlock1.Text = val;
but it didn't work!
Don't use ComboBox on Windows Phone. Instead use the ListPicker from the Silverlight Toolkit.
In fact I had to choose "SelectionBoxItem" instead of "SelectedItem" , i finally found it !Thanks everybody for the help ;-)
Related
I have an autocomplete textview and I am setting an Adapter view on it to show the list of suggestions. While testing on espresso, I want to select an item position from list of suggestions but, it does not identify the auto complete text view adapter on espresso.
I tried this answer from Stack overflow:
DropDown value selection using espresso android with dynamic element id's
But, this did not work for me. Any help on this would be great.
Thanks.
or you can try instead onData. Because onData not working for me
onView(withText("Your field name"))
.inRoot(withDecorView(not(is(getActivity().getWindow().getDecorView()))))
.perform(click());
I run into the same problem and this is how i did it:
onView(withId(R.id.sp_country/*auto complete textview*/)).perform(click());
onData(allOf(is(instanceOf(String.class)), is(COUNTRY/*selected value autocomplete collection*/)))
.inRoot(RootMatchers.withDecorView(not(is(activityActivityTestRule
.getActivity().getWindow().getDecorView()))))
.perform(click());
I'm building a UI in Google Sites using Apps Script and I am able to create a listbox. According to the documentation if you change the setVisibleItemCount to 1 it will become a dropdown box.
I have tried both 1 and 0.
Neither seems to make it a drop-down box. Using Firefox 13.0.1 to view. Have also tried Safari.
Anyone had any luck with this?
Code looks like this:
var vPanel = container.createVerticalPanel();
//List box
var lb = container.createListBox(true).setId('listbox').setName('listbox');
// add items to ListBox
for(var i=0;i<LIST_OF_PROJECTS.length;i++){
lb.addItem(LIST_OF_PROJECTS[i]);
}
vPanel.add(lb);
lb.setVisibleItemCount(1); //supposed to make it a drop-down but doesn't
lb.setSelectedIndex(0);
This is all inside a Google Site and the page that is being displayed is a Apps Script Page. Perhaps you are NOT using Google Sites? Above code gives me a single line but no drop down arrow.
Could you post your relevant code please ?, It's working for me on firefox (slightly differently), chrome & safari. (see screen cap when I click the selector, SetVisibleItemCount is 1)
thx
EDIT : One important point : to get the list acting as a dropdown list you have to choose 'disable multiple selection', in other words : createListBox(false) or no parameter... but not 'true' as it is in your code !! (now we know why it doesn't work in your case ;-)
With this parameter set to false , it works as expected in standalone webapp, embedded on site and linked to spreadsheet without any difference.
Don't call:
setVisibleItemCount
at all.
I am trying to create an app with no of clearable textboxes (a textbox with a 'x' inside, on clicking 'x' datas gets cleared in textbox).
I gone thru 2 links this one and this one, it wasnt helpful.
Can any one help to create a function for it?
not sure what the exactly problem you are facing. you can achieve this by having a textbox and a roundbutton (coding4fun) in a grid (adjacent columns)
the tap on button clears the textbox. you can even create yourself a nice user control that wraps the code nicely so you can have multiple instances.
Something like that?
public TextBox CreateTextBox(string defaultText)
{
var tb = new TextBox { Text = defaultText };
tb.GotFocus += new RoutedEventHandler((object sender, RoutedEventArgs e) =>
{
if (tb.Text == defaultText)
tb.Text = "";
});
return tb;
}
Full Disclosure: I work at Telerik and our TextBox has this functionality built in:
http://www.telerik.com/products/windows-phone/overview/all-controls.aspx
You missed out this Link. It has a custom control "ClearableTextbox" which may suit your requirements.
You can download the source code which includes the dll file as well.
Include a reference to that dll in your project and then add the following line in the xaml page,
xmlns:clrtb="clr-namespace:ClearableTextBox;assembly=ClearableTextBox"
And then you can use the textbox something like,
<clrtb:ClearableTextBox Width="300" Height="60" VerticalAlignment="Top"/>
As the source code is available, you can make some modifications to it, so that it fits your requirements
UPDATE:
Alternately, I found this great control which makes your task easy:
PhoneTextBox in SilverlightWP7 toolkit
I have a ListPicker which is filled dynamically in code.
How can I set style of every ListPickerItem which has been added from code?
Or how can I set style of future items of ListPicker in XAML?
Thanks.
Try this =>
yourListPickerItem.Style = (Style)FindResource("NameOfYourStyle");
EDIT : Silverlight does not implement the FindResource method that exists in the WPF framework API. So, check http://blog.functionalfun.net/2011/01/findresource-implementation-for.html
I find a way to get ListView's selected item full path. I do it in treeview by using this:
temp = (HTREEITEM)SendDlgItemMessage(hWnd,ID_TREE,TVM_GETNEXTITEM,TVGN_PARENT,(LPARAM)temp);
But I don't find familiar method in listview controls.
THanks for reading this and I w8 for your answers :)
Use the LVM_GETNEXTITEM message, specifying LVNI_SELECTED as lParam, and then the LVM_GETITEMTEXT message.