GWT Watermarked (AKA placeholder) ListBox - user-interface

I want to have in my gwt application a ListBox with a watermark.
I already created TextBox and a DateBox with a watermark by extending those classes and the property placeholder of the DOM.
However I could not such property for the ListBox. There isn't any, right? (how can I tell? except for trying.)
Assuming that there is no such property I would like to implement such a class by extending ListBox.
I am not sure how such a ListBox would behave.
could you please help me define the behaviour of such ListBox or maybe you know a site that uses one so I could play with it? Or just point me to a code example.
Thanks

I would think it would be a non editable list item as the placeholder. You could have the setPlaceholder set the text on the list item. The placeholder list item would only be visible when the list was empty. You couldn't select the list item, and all methods to access list items would never see it.

Related

WP7 Listbox Binding: Changing image uri in does not reflect in listbox

I have a view with a list box, bound to am obvervable collection of DisplayItems, which has 'Label', 'DisplayValue' and 'IconUri' properties.
I have a View Model which exposes this observable collection. The List Box is correctly populated first time around.
I then have a button which takes action on the selected item. I need to indicate that action has been taken by changing the image.
I am changing the IconUri of the selected item, and can see the new value present when debugging, but the image doesn't change. I can also change the 'Label' and 'DisplayValue' properties and see the new values correctly there when debugging, but the list doesn't change.
My ViewModel implements INotifyPropertyChanged. My DisplayItem class implements INotifyPropertyChanged. I'm calling RaisePropertyChanged I'm sure in too many places rather than too few.
None of the changes are ever reflected on screen.
I'm using a DataItemTemplate for the generated rows. If I could access the image of the selected row I could change it manually, but I can't even do that.
Any help greatly appreciated. I could actually do with a example of a list box displaying items from a bound observable collection, where one property of the selected item is changed and that change is reflected in the list box.
Thanks in advance
A
You didn't implement INotifyPropertyChanged correctly, or you're using it wrong.

How to get a textbox for an item in longlist selector for WP7

I am developing a wp7 application using longlist selector. My requirement is to change font of only some items on the screen. For this i need to get the text box control for the item.
The textbox is a part of item template of the long list selector.
The items to be modified change with the scroll.
I tried using the Link event. here i can find the contentpresenter for the item being added. But how can i get the textbox from the content presenter.
Any one can help with this? pls.
Instead of searching for the TextBlock that gets generated - provide your own in the ItemTemplate/DataTemplate and set its font through binding to an item in the ItemsSource. You can use a converter to determine the font or provide the font directly in each item of the bound collection.

Unify ViewModel through-out UserControl

I'd like to know how to set a single ViewModel throughout a single UserControl. I'm using an Items container inside a user control (bound to ItemsSource) and it doesn't seem to update with the code-behind replacement of a DataContext (to a code-behind instantiated ViewModel)
What i'm trying to do is change the DataBound foreground color of every text Item in the userControl, and the items inside an Itemscontrol dont seem to change. forcing a datacontext change removed the collection items from display.
I think I'm conceptually Misunderstood here. could anyone help?
I could fix the problem by using Storyboards to change color but the problem was still the same. The eventual solution was to access the resources inside the templates, which is possible by browsing the Visual Tree as shown in this tutorial
http://windowsphonegeek.com/tips/how-to-access-a-control-placed-inside-listbox-itemtemplate-in-wp7
The peculiar thing though, was that I needed to look for my object inside the initial object returned, as it seems to return the System generated one, which you don't see yourself. Looking for the answer inside this one helped. Also, pushing them into a list of items for easy access later could be a general idea, but MS needs to fix the way of doing this pronto.
I would recommend binding the ItemsSource to a property in your ViewModel.

UserControl instead of DataTemplates - is there a way for big collections?

There are two ways. May be both are stupid...
I have to display some collections of items.
First one.
I use DataTemplate for ListBoxItem.
Just set itemSource = myCollection;
That's all. Simple scheme.
Second one.
Each item in my collection has property view. It's a UserControl. That define how item renders.
Create DataTemplate with ContentPresenter only.
Binding Content property to a view.
Just set itemSource = myCollection;
That's all. More complex. But works too.
Has second one right to live? My doubt is that I have to create instance of UserControl for every item in my collection?
Is not it too expensive for collection with over than 500 items?
Thanks.
I don't believe there is much difference, with the DataTemplate approach the framework will create an instance of the DataTemplate for each item in the collection. In the second approach an instance of the user control will be created for each item, there may be a few more controls but only a few per item.
One reason the second approach could be preferable is that you can have logic around which content is bound. This could mean different user controls for each item in the list. Caliburn Micro lets you use this approach very naturally.

How to bind test data to a SketchFlow ComboBox?

I haven't been able to successfully bind some test data to a SketchFlow ComboBox. I added a sample data source and created a collection with some basic string values. There are a number of tutorials on how to bind to a ListBox in SketchFlow and that works fine, just not finding anything for a ComboBox.
One thing that caught me out a few times is that you need to have your data in "list mode" before you drag it on to the control (combo box or list box).
It seems to work as I expected, so perhaps I'm not understanding your issue correctly, but I'll give it a shot! I created a sample DataSource with a couple of strings in it, added a ComboBox to the layout root and then just dragged the Collection from the DataSource and dropped it on the ComboBox.
Keep in mind that if you drag the DataSource itself, you'll only be setting the DataContext property of the ComboBox and that's not enough to get your items to display. You also need the ItemsSource bound to the Collection of the DataSource and an ItemTemplate or a DisplayMemberPath to tell the ComboBox how to display your items.
Additionally, if you use the drag and drop method of binding, it will use the ItemTemplate approach for you, which may or may not be what you want as it will generally create a StackPanel and display all fields from the row in your Collection per item in the ComboBox. You can remove the ItemTemplate and set DisplayMemberPath to whichever field you wish to have displayed from your data source's collection.

Resources