Customizable tiles inside app - windows-phone-7

I want to display items as tiles inside my app. The HubTile control is to inflexible for me, so I use this solution with a listbox. I have a few types of items and they should be displayed differently. For example, the note item has a title and a text while the image item has a image source and a name.
Implement two styles for note and image and creating the ListBoxItem dynamically with each style seems to me as an easy way, but is it the best solution?

When you have an ItemsControl that has mutliple data types in its ItemsSource and each data type has a different DataTemplate, you should use something like DataTemplateSelector.
I've written about this topic in the context of WP7/WP8 # ListBox with multiple ItemTemplates in Windows Phone 8

Related

Implementing a "fisheye" view with a ListBox

I am new to Windows Phone Programming. In my application, I Have a listbox which lists the phone contacts. Currently it is listed as a regular list with equal size for list items in the UI.I am looking to modify the front end like this :
I dont want to have different sizes /back ground color for each list items rather a fixed UI and let the lists scroll through it and the list item in the view, at any time, should be displayed as in the picture.
I dont expect any codes as answers but any examples are welcome too, just want to know using what feature this kind of functionality is possible so that i can do my reading!
Thanks,
Deepak
It would be difficult to modify an existing control (ListBox for example) to act like this, so your best bet would probably be an ItemsControl with its RenderTransform set as a TranslateTransform.
If you place a Rectangle (with Fill="Transparent") over the ItemsControl, you can attach handlers to the ManipulationStarted, ManipulationDelta, and ManipulationCompleted events to control the "scrolling" by setting the TranslateTransform's Y offset.
To resize the items in the list there are two options: a custom panel or manual setting.
Custom Panel
You could create a custom Panel implementation that will appropriately resize its Children based on a property you would create to represent the scroll position. Set the ItemsControl to use your panel, and either through binding or attaching a handler to the panel's Loaded event and keeping a pointer to the panel, update the aforementioned property from inside the ManipulationDelta handler.
Manual Setting
From inside of the ManipulationDelta handler, you can also calculate the various heights of the boxes and use MyItemsControl.ItemContainerGenerator.ContainerFromIndex to get the visual for each item and set its height.
I would suggest putting this all inside of a custom UserControl.
You may have issues with clipping using the TranslateTransform but hopefully this will get you started. Unfortunately, this looks like a rather difficult control to try making as your first windows phone project!
So Finally I did manage to find a way to do it.
First approach was as #Murkaeus suggested, Using UserControl and ManipulationDelta event handler. However for some reason the manipulationDelta event was triggered only for 2 finger gestures (Zoom, Pinch..etc), I have no clue why. And after some trying I had to give up on this.
The next approach was using Listbox itself. The source of the Listbox was set as the List( of Models objects) that I create after reading the contact information from phone. The height and color of the listbox item was bound to a property in my model named "scaleLevel" and was accordingly converted by implementing IValueConvertors to give predefined color and height values for different scale levels.
I created an attached property for the scrollviewer vertical offset like mentioned [here] (http://www.scottlogic.co.uk/blog/colin/2010/07/exposing-and-binding-to-a-silverlight-scrollviewer%E2%80%99s-scrollbars/)!
This event is triggered on change of the vertical offset and every time there is a scroll, I find out which listbox item to be enlarged and which reduced based current vertical offset.
Once I have this information, I change the property ("scaleLevel") of the affected items in the List (of Model) (which is bound to listbox height and color). This change is updated in UI using the INotifyPropertyChanged Event.
I have no idea if this the best way of doing it , but it works well and there is no considerable in updating the UI despite the processing involved.
I would like to hear your opinion about the implementation and any other solution which you feel will work better.

WebBrowser as ListItem and scroll

This question about WP8 project.
I have a LongListSelector with pictures and html formatted text below. Currently each pictire implemented as an Item of the list. The last Item with browser has its own template and shows WebBrowser instead of picture.
I am expected this item behave such as TextBox which I can scroll by interacting with LongListSelector.
But this WebBrowser has it's own scroll inside and intercepts any surrounding scrolling events. Thus whenever I scroll down the list to show WebBrowserControl to the whole screen, I can't go back to the pictures.
Please help me with this issue. What is the appropriate solution? I need a separate pictures since want to implement "Clicked" logic on top of it. And I want to have WebBrowser too (but prefer to behave it similar to RichTextBox (which I can't find in WP8))
USE ListBox.ItemTemplate along with DataTemplate and inside dataTemplate we could custom create xaml tag !

In WinRT we have ListView and GridView - how about a simple list with columns and details (like Explorer details view)

I just want to create a list with data and columns (sortable). I don't want tiles, I don't want right scrolling. I just want a list like the "Listview" Win32 common control. Or am I forced into the tile metaphor.
I believe they are not at a metaphor but from my point ListView in Win32 is one.
ListView in Win32 is a very limited control, unflexible and too ugly.
ListView and GridView xaml controls are far better aproach, I know.. switch from old style controls to new style is easy if you come from scratch but if you have old style background... is hard... I know.
If your lvw32 grows vertically based on data use a Listview (xaml) in wich each item is a Row and use the item template to put in a gridview,the gridview will be one register with all attributes (columns).
So your ListView will have a collection of Rows, each Row is a GridView who is a Collection of attributes.
This is a way, but you have a lot of different options.

Expand WP7 content element on tap

Is there any way or are there any elements in WP7 which could be expanded on tap? For example if I'm using a ItemViewModel I'd like to show only the content of LineOne and when that is tapped I want to show the content of LineTwo.
I don't necessarily need to do this with a ItemViewModel. For example the hidden content could also be buttons that appear instead of a line of text.
Any suggestions?
Have you looked into the ExpanderView from the Silverlight Toolkit? It allows you to have a tap-to-expand template and a standard template. There's a reasonable overview of it available at Windowsphonegeek

How do I make an NSPopupButton that has a menu with images AND text?

I have a list of applications and I'd like to make an NSPopupButton that shows a menu of application names with their icon to the left of each item.
I've been able to bind the NSPopupButton to my array of items, but there isn't a binding entry for an image. I thought I could put a cell in there and bind the cell as an image and as text, but I can't find an appropriate cell in IB.
Is there a clean and simple way to do this using bindings? Do I have to write a custom cell?
There is no way to bind the images as well as the titles of the menu items using a stock NSPopUpButton. You will have to subclass it and write an IBPlugin to expose the subclass. And, of course, you should handle the cell as well.
I've found mixing Bindings with NSPopUpButton to be a bag of hurt for a variety of reasons, including the impossibility of separators and of out-of-model menu items such as “Default” or “All”. Consider using a different control, such as a source list, or populating and re-populating the pop-up menu manually.
NSMenuItem has Image binding (in "Parameters" section waaaaaayyyyy down). So I think that you should bind that value to a path in your array of running applications. You can get an icon for your app using shared NSWorkspace object.

Resources