How to deselect items in listview (bound to List<myObject>) programmatically in Windows Phone 8.1 - windows-phone-8.1

It's Windows Phone 8.1 Universal.
I need to be able to select and deselect items in the listview.
I can't select/deselect a single item programmatically, but I can select all items in the listView with this method:
listView.SelectAll();
It would make sense to expect the exact opposite method built-in to deselect all, but there is none.
I can't use the following code because it's not bound to a list of ListItem object, but a custom object
foreach (var item in listView.SelectedItems)
{
//item.IsSelected isn't available because it's a custom object
}
How do I deselect all items in the listview?

If figured it. The following code deselects all items in the listView:
listView.SelectedItems.Clear();

The other way is listiew.SelectedIndex = -1;

Related

Returning selected value from scala swing ListView

I have a scala program that collects elements from database and small GUI that offers search conditions and displays desired selection of these elements in scala swing listview. For next step in program i'd like user to select one item and by clicking a button feed it to next part.
Listview is updating just fine, i'm listening to right place for what it comes about selection but for some reason ListView.selection.items(0) is not updating when selected item changes. Whatever i choose first will stay there despite for example changing whole listview.listData of elements.
lazy val ui = new FlowPanel {
val listView = new ListView( Seq("spam", "eggs", "ham") )
listenTo(listView.selection)
reactions += {
case SelectionChanged(`listView`) => println(listView.selection.items(0))
}
contents += listView }
This is something that shoud work, and very similar to what had figured out myself. This was found from Scala Swing Popup menu on ListView answers but instead of printing selected items it just continues printing the same value i choose in first place whenever my selection changes.
Is there some manual way of telling selection to update its items or whatever could make this work. I could use ComboBox, but it would be more userfriendly to show available selections on list on a scrollpane so i'd prefer finding answer to my problem.
Im using scala version 2.11.7 and swing 2.11.0
Edit: version "org.scala-lang" % "scala-swing" % "2.11.0-M7" in build seems to be the source of problem.

Windows Phone 8.1 (runtime) additional data in OnMapTapped event

I am trying to create a Windows Phone 8.1 (Runtime) app that has a Map Control on it. I would like to attach additional data to the OnMappedTapped event or a way to grab an assigned Location ID when someone clicks on the MapIcon. Is this possible?
Yes. If you want to do something when someone clicks on a MapIcon (pushpin), then add a tap to the map and then do a search for elements that intersect the touch point using the Map.FindMapElementsAtOffset method: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.maps.mapcontrol.findmapelementsatoffset.aspx
or the Map.FindSubElementsForTouchTargeting method: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.uielement.findsubelementsfortouchtargeting.aspx
When it comes to storing or associating data to a pushpin, I like to store my data in the standard Tag property as that's something I've been doing for a while with WPF and Silverlight. You will notice that the MapIcon/MapElement classes do not have a Tag property, however they are DependancyObjects which meanswe can easily add custom properties to these classes. Here is a simple extension I often use in my WP apps to add a Tag property to these classes.
public static class MapElementExt
{
public static readonly DependencyProperty TagProperty = DependencyProperty.Register("Tag", typeof(object), typeof(MapElement), new PropertyMetadata(null));
}
You can then set this value like this:
pushpin.SetValue(MapElementExt.TagProperty, MyPinData);
Personally, when it comes to pushpins I normally don't mess with the MapIcon/MapElement classes and just create a UIElement for my pushpin. By doing this I can easily have a lot more control over creating my pushpin and can also easily add Tap events. You can specify the location for a UIElement like this:
MapControl.SetLocation(pushpin, MyGeopoint);
And then add the pushpin to the Map.Children property.
If you want to get the coordinates for a randomly selected point on a map through a touch event you can take the pixel coordinates from the tap event and pass them through the Map.GetLocationFromOffset method. For example:
MyMap.Tapped += (s, e) =>
{
Geopoint loc;
MyMap.GetLocationFromOffset(e.GetPosition(MyMap), out loc);
};

Bind TreeView.SelectedItem to a property in the ViewModel in a WinRT app

In my Windows Store XAML app I’m using the TreeView control from the WinRTXamlToolkit and I’m attempting to two-way bind the SelectedItem property to a property on a ViewModel.
Out of the box, the SelectedItem property is read only and this makes sense because the control supports Virtualization.
I have seen some folk work around this with things like attached properties, helper methods and so forth, a great example of which is seen in this question
WPF MVVM TreeView SelectedItem
But all of the questions/solutions are not based on WinRT and all of my attempts to rework the solution code for a WinRT app have proven fruitless.
So, my question is, is this possible in a WinRT app? What am I missing?
Thanks
I'd skip trying to come up with a bindable property globally for the view model and instead use the IsSelectedBindingPath and IsExpandedBindingPath properties of the TreeView as in the debugging tools' example of the control's usage. Then when you want to select/expand an item from the view model - use a method similar to SelectItem() in my view model where I essentially set IsExpanded/IsSelected to true in item/node view models throughout the path from the root of the view model tree and load the content of the tree if the nodes in the expected path do not exist.

How to bind caliburn.micro view model to WP8 LongListSelector control?

Is there a way to automagically bind a Caliburn.Micro view model to the Windows Phone 8 LongListSelector control and auto-wire the SelectedItem property?
If i understand your question correctly, then you want normal Caliburn.Micro conventions to be applied to the LongListSelector control.
I don't work with Windows Phone development but i think it can be done by calling the following line of code in the Configure() method of the bootstrapper.
ConventionManager.AddElementConvention<LongListSelector>(LongListSelector.ItemsSourceProperty, "SelectedItem", "SelectionChanged");
This code tells Caliburn.Micro to use the ItemsSource property whenever it a finds a named (e.g. x:Name="myList") LongListSelector and to use the SelectedItem whenever a LongListSelector element is passed in the parameter list of an action message, and finally it uses the SelectionChanged event to fire action messages by default.

Prevent Scaleform TileList from filling last row with disabled ItemListRenderer objects?

I'm using Actionscript 3 and Scaleform 4.1 to command an instance of a TileList in a Flash project (CS 5.5).
I have got the TileList populating with ListItemRenderer objects (basically buttons).
In my current situation, I need rows of 4, but I need to place 15 buttons (design requirement). The TileList automatically populates the final row with 3 buttons, and one Disabled state button (instead of a blank space).
So the question:
Can you prevent the TileList from placing Disabled buttons (ListItemRenderer) in remainder spaces?
Is the TileList required to fill a grid to capacity (with Disabled buttons if necessary)?
Can you force a TileList to leave remainder spaces empty?
Alternate solutions also welcome, i.e. can you add another state to the ListItemRenderer such as "blank"? If so, how would you force TileList to default to that instead of Disabled?
If there is good documentation available on this, I don't mind an RTFM reply with a link, but I haven't found anything after a couple days scrounging. Thanks!
It is certainly possible to extend or modify the TileList to suit your needs. That is why we've released CLIK's source. But to answer your question, by Default, the Tilelist is set up to use a blank/disabled renderer for empty tiles.
You can handle this without extending the tilelist, but instead the item renderer itself (much more common anyway for displaying your custom data). The 'disabled' renderer's will all get setdata(null) called on them. Thus just override setdata to toggle the visibility when that is the case:
if ( data != null )
{
//do stuff with data
visible = true;
}
else
{
visible = false;
}