LongListMultiSelector - can you Suppress the Default Tap Behaviour that puts List into edit mode? - windows-phone-8

Ok, I hope this doesn't have an embarrassingly obvious answer, but I could not find a solution through searching.
I'd like my longlistmulti to function basically like the Mail app, i.e. having the "select" appbar button put the list into Edit mode, so you can perform operations on it.
However I'd like to suppress the behavior where the list is responding to a tap on the left side of any of the items, that first 10% part of the item's width, that puts the List in the Edit mode.
I have a button as part of the item template, that is pretty flush against the left side, that I need as a trigger for it's own event handler for each item.
So I just want to block the event that is putting it into edit mode via tapping on items. Hope this can be done.
Steve
A quick addit'l note: I'd like to suppress this default behavior regardless, even if I do decide to not have that button as my final implementation.. i didn't want to factor that button as a permanent consideration.

You have a couple of options here. One is handling the IsSelectionEnabledChanged event, and the other is modifying the control template. If you want to place the list into edit mode yourself, I'd suggest using the template modification method, as the event handler might be a bit convoluted when it comes to determining where the change event came from.
From the Document Outline pane (CTRL+W, U to make visible), right click your list control, and navigate to Edit Additional Templates => Edit ItemContainerStyle => Edit a Copy... Use the dialog to name and place the template in your preferred resource dictionary. Look for the rectangles named InnerHintPanel and OuterHintPanel and delete them. This will remove the hit area for activating edit mode. The XAML for these rectangles is reproduced below.
<Grid HorizontalAlignment="Stretch">
...
<Rectangle x:Name="InnerHintPanel" Grid.Column="0" Width="24"
Height="{TemplateBinding HintPanelHeight}"
HorizontalAlignment="Left"
Fill="Transparent"
StrokeThickness="0">
<Rectangle.RenderTransform>
<CompositeTransform TranslateX="24"/>
</Rectangle.RenderTransform>
</Rectangle>
...
</Grid>
<Rectangle x:Name="OuterHintPanel" Width="24"
HorizontalAlignment="Left"
Height="{TemplateBinding HintPanelHeight}"
Fill="{TemplateBinding Background}"
StrokeThickness="0" Opacity="0.0"/>
You should probably delete all storyboard animations that have Storyboard.TargetName set to one of these elements' names as well, otherwise the transition in control state will cause exceptions if you enter edit mode and those elements cannot be found.

Related

Can we use longlistselector inside a popup in Windows phone 8?

How to use longlistselector inside a popup control?
If not possible, then any other way to show longlistselector/listbox as a popup ?
As a popup you can you CustomMessageBox. Instances of CustomMessageBox have property Content, that has no differences from the Content property of any other content controls. So you can put there LongListSelector or ListBox or whatever you want (even Pivot and Panorama), than call Show method. CustomMessageBox will close if user'll click one of the 2 default buttons, but you can hide them (properties IsLeftButtonEnabled and IsRightButtonEnabled) and close CustomMessageBox by your own logic by calling Dismiss method. There is a couple of useful events: the most useful is Dismissed, that raises right after CustomMessageBox get closed (dismissed), its handler contains DismissedEventArgs, that has result of users choiсe (right or left button was chosen, if they were on the screen) and of course sender (CustomMessageBox). If you want some logic after CustomMessageBox closing, use Dismissed event, Show method won't stop program flow.
This is the easiest way to show something. It's not a popup, but it behaves like it.
But if you wont to use popup ifself, there is Child property for you, put there Grid, and ListBox inside the Grid. But you have to set the values of the Width and Height of popup Child.
You can create a new Page and simply put your LongListSelector in it.
For example (Page is called MyPopupPage):
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<con:LongListSelector x:Name="LongListSelector">
<con:LongListSelector.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</con:LongListSelector.ItemTemplate>
</con:LongListSelector>
</Grid>
Then fill it with whatever you want (Refer to: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj244365(v=vs.105).aspx)
In your MainPage (the page which should open the popup):
Create an object of type Popup like:
Popup LLSPopup = new Popup();
And create a Method to set the MyPopupPage as the overlay of the popup:
private void ShowPopup()
{
MyPopupPage ovr = new MyPopupPage();
this.LLSPopup.Child = ovr;
this.LLSPopup.IsOpen = true;
}

Longlist selector with Checkboxes

I am developing app in WIndows phone 8 and using LLS with this data template..
<phone:LongListSelector Name="longlist">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding property1, Mode=TwoWay}" Content="Hii" Checked="CheckBox_Checked_1" Unchecked="CheckBox_Unchecked_1"/>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>
While I checked one and scroll list the checkbox selection is changed suppose I select first it shows up me 2 is selected or no-one is selected means behave differently..I am using code in .CS in this link...
http://pastie.org/7938678
please suggest me how can I get rid off this problem..
That is by design. You just tapped a check box inside a list item, thereby selecting it.
I suggest you don't rely on list selection position changed, use another event like Tap instead in your DataTemplate to drive any actions you have based on a list item.
If you want only 1 Item selected at a time use a RadioButton instead of a CheckBox. After this you need to define the GroupName Property.
See the code of my answer below:
How to highlight a selected item in the LongListSelector on WP8?

Force GridView To Create Not Recycle Controls

I have a GridView in a windows store app that has an ItemContainerStyleSelector. Within the style is an Image control that has a custom dependency property to set the source (This is so I can get a handle on the Image and hook up to the unloaded event).
My issue is the Image is never unloaded and seems to be reused. This means that when I set the source, the image is set on other items in the GridView as well (For Example I have an object which has no image but after scrolling away and then back again it has an image from another object).
I've tried to set virtualization mode to standard where I can but it doesn't help. Any ideas would be greatly appreciated.
Here is the Image that is contained in the style. This is passed to a method "OnRemoteURISourceChanged" when set. I'd expect a different image control whenever the method is called but this is not the case.
<Image x:Name="BackgroundImage" DataContext="{Binding CurrentBackdrop}" helpers:ImageExtensions.RemoteURISource="{Binding Uri}" Stretch="UniformToFill"/>
And here is my GridView
<GridView x:Name="ItemsGrid" Grid.Row="1" ItemsSource="{Binding BrowseResults}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Margin="20,0,20,0"
IsItemClickEnabled="True" ItemClick="ItemsGrid_ItemClick" VirtualizingStackPanel.VirtualizationMode="Standard">
<GridView.ItemContainerStyleSelector>
<controls:UPnPCDStyleSelector CDObject="{StaticResource somestyle1}" Container="{StaticResource somestyle2}" Item="{StaticResource somestyle3}"/>
</GridView.ItemContainerStyleSelector>
<GridView.ItemsPanel>
<ItemsPanelTemplate VirtualizingStackPanel.VirtualizationMode="Standard">
<WrapGrid Orientation="Vertical" VirtualizingStackPanel.VirtualizationMode="Standard"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
UPDATE: The issue appears to be the WrapGrid. If I change this to a VirtualizingStack Panel and set the VirtualizationMode to Standard then everything works as expected but obviously my items then only appear on one line and not multiple lines as I wish.
How do I set the virtualization mode of a WrapGrid?
Is there a chance your helpers:ImageExtensions.RemoteURISource doesn't clear the Image.Source when either your CurrentBackdrop property or its Uri property value is null?
Are you sure the task which is loading the img source returns to default ui context when awaiting? I don't think it is a good idea to set Image.Source property form code. The better solution would be to create a custom observable task class and bind im source to it's result. In the background you can call the task. Do you need the control to be Image? Because if it would be a control with template, it would be easier for you to do that. I can send you the class which does that if you want to.

active content property on tab change

I want to create binding in code that will jump when the user is navigating between tabs,
or when ever a tab is created.
I tried to bind the dependency property active content property, and from some reason it doesn't work.
thanks.
What may help is to explicitly set a TwoWay binding:
<avalondock:DockingManager ActiveContent="{Binding DocumentManager.ActiveDocument,
Mode=TwoWay}" />

flex DateChooser needs to not be selectable

I'm sure this is pretty easy but I'm at a loss with this one. I have a DateChooser that I'm using to highlight dates when things are being released. And that's all I want it for. I want to turn off the ability for users to click on anything. I don't see how to have selectable false. Anyone know?
Thanks
There are actually two properties that you can use to turn off user interaction:
First is the enabled property, set it enabled="false" in mxml and user
interaction will be disabled. However, Flex will render the
DateChooser dim (kind of faded away).
<mx:DateChooser id="date1" enabled="false" />
Another option is the mouseChildren property, if you set it to
mouseChildren="false" as well all children of the display object will not be enabled, in the case of the DateChooser it disables all user interaction too.
<mx:DateChooser id="date1" mouseChildren="false" />
Try placing it behind a Group that has a fill with alfa 0. That way the group will take the clicks and do nothing with them.
If i understand you correctly, then you could use the disabledDays, disabledRange or selectableRange properties of the DateChooser. E.g. such as in the code from the adobe website:
<mx:DateChooser
selectableRange="{{rangeStart: new Date(2006,0,1),
rangeEnd: new Date(2006,2,15)}}"
disabledRanges="{[new Date(2006,0,11),
{rangeStart: new Date(2006,0,23), rangeEnd: new Date(2006,1,10)}]}"
disabledDays="{[0,6]}"/>
Use this to disable all other dates than the one(s) you want highlighted. I was actually just wondering if i should do something similar, but I just ended opp using a disabled DateField(enabled=false) to display the date. I hope this helps :)