I have a very basic SemanticZoom implementation within my Windows 8 app. This app has the following xaml:
<SemanticZoom x:Name="semanticZoom" VerticalAlignment="Stretch" IsZoomedInViewActive="False">
<SemanticZoom.ZoomedOutView>
<GridView x:Name="myGridView" ItemsSource="{Binding Source={StaticResource orderViewSource}}" ScrollViewer.IsHorizontalScrollChainingEnabled="False" SelectionMode="None" IsItemClickEnabled="True" ItemClick="orderGridView_ItemClick">
</GridView>
</SemanticZoom.ZoomedOutView>
...
</SemanticZoom>
Oddly, the orderGridView_ItemClick event never fires when I click an item. I've heard that the semantic zoom control catches it, and doesn't bubble it down. If that's the case though, there should still be a way for me to see which item was selected. How do I determine what item an user clicks from the ZoomedOutView within a SemanticZoom control?
Thank you!
Related
In Xamarin.Forms I have a simple ListView that is bound to a view model using MVVM.
<ListView Grid.Row="1"
ItemsSource="{Binding ContactsGrouped}"
IsGroupingEnabled="true"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsRefreshing}"
GroupDisplayBinding="{Binding Key}"
GroupShortNameBinding="{Binding Key}"
BackgroundColor="Transparent"
SelectionMode="Single"
HasUnevenRows="true"
SeparatorColor="#cccccc">
<ListView.ItemTemplate>
<cr:MyItemTemplate>
</ListView.ItemTemplate>
</ListView>
This is my xaml code, which works perfectly fine if the list has at least 1 item. By tapping and pulling down on the item, the list view refreshes fine, however tapping and pulling down outside of the item, the list does not cause PullToRefresh to occur. It's almost as if the ListView has transparent input but its items do not, thus allowing it to work.
Anything in the red in my example image shows the area where if I tap and drag down the activity indicator appears fine and the refresh happens. Tap and dragging anywhere in the green however causes the View to not refresh and the activity indicator to not appear.
I won't show my view model as the issue is with the View. I've also tried setting background color to red, checking if transparent was causing an issue, sadly that is not the case. Any ideas?
I just reproduced your problem on my side. After some researching, I found it is known issue from Xamarin.forms 3.5.0 and it still exist in Latest stable 3.6.0.344457.
The WorkAround is downgrade your Xamarin.forms version to 3.4.0.
Also, I test it in the Latest prerelease 4.0.0.394984-pre10 and it works well. So, I believe this issue will be solved in the next release version.
You can follow this issue to check the process.
Try adding VerticalOptions="StartAndExpand".
<ListView Grid.Row="1"
ItemsSource="{Binding ContactsGrouped}"
IsGroupingEnabled="true"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsRefreshing}"
GroupDisplayBinding="{Binding Key}"
GroupShortNameBinding="{Binding Key}"
BackgroundColor="Transparent"
SelectionMode="Single"
HasUnevenRows="true"
SeparatorColor="#cccccc"
VerticalOptions="StartAndExpand">
<ListView.ItemTemplate>
<cr:MyItemTemplate>
</ListView.ItemTemplate>
</ListView>
This property tells the View how much space of your screen should it cover. If you don't add it then the View will just cover whatever the required length to display the data it needs.
I want to show a simple flyout menu on a gridviewitem. According to this article here: https://blogs.msdn.microsoft.com/winuiautomation/2016/01/01/ten-questions-on-programmatic-accessibility/, (paragraph 6) you should be able to just set up a handler for the doubletapped event. I also tested it in the windows phone ui.
The problem is that ,in my app, the doubletap handler never gets called when doing the 2-finger double-tap gesture while narrator is activated.
I tried to do this in my gridview:
<GridView x:Name="ImgGrid"
ItemsSource="{x:Bind AllFiles, Mode=OneWay}"
IsItemClickEnabled="True"
SelectionMode="None"
Background="{ThemeResource PaneBackgroundBrush}" Padding="8"
ItemClick="ImgGrid_ItemClick"
ItemContainerStyle="{StaticResource GridViewItemContainerStyle}"
IsDoubleTapEnabled="True"
DoubleTapped="ImgGrid_DoubleTapped">
As you can see, the doubletapped flag is enabled and there's a handler attached for the doubletapped event. But it doesn't get called with the 2-finger double tapped gesture. However, on non-mobile devices, the handler gets called by rightclicking on a gridview item.
I also tried to put the eventhandler on the gridviewitem itself:
<DataTemplate x:DataType="data:KNFBFileInfo">
<Grid x:Name="ThumbnailContainer"
Margin="8"
Width="80"
Background="Transparent"
MinHeight="100"
Height="Auto"
Holding="ThumbnailContainer_Holding"
RightTapped="ThumbnailContainer_RightTapped">
Same result as the first thing i tried...
It's really a shame that it's so hard for a developer to make
his app accessible
I just created a sample app with MenyFlyout inside DataTemplate
<DataTemplate x:Name="LastItems">
<Grid RightTapped="Grid_RightTapped">
<FlyoutBase.AttachedFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Item1"/>
<MenuFlyoutItem Text="Item2"/>
<MenuFlyoutItem Text="Item3"/>
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
<TextBlock Text="{Binding ''}" Padding="10" Margin="10,0" />
</Grid>
</DataTemplate>
And then Grid_RightTapped method is as follows.
private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
if (element != null) FlyoutBase.ShowAttachedFlyout(element);
}
Doing this, When I Right Click on Non-Mobile Devices and LongPress on Items on Mobile Devices, Flyout Shows up with no issues.
There is an official document about the "Narrator". When we Double-tap with one finger, or Hold with one finger and tap with a second, it will activate primary action. It means we tap the item once without the "Narrator". So the DoubleTapped event will never be fired.
When we Double-tap with two fingers, it will show the context menu of the select control. We should be able to add the RightTapped to the GridView. When we Double-tap with two fingers, the RightTapped will be fired.
It seems we can not select the GridViewItem in the "Narrator" mode. If we add the SelectionChanged event to the GridView, when we double tap the GridViewItem, the SelectionChanged will never be fired.
In WPF, is there any way to disable the scroll behavior of the ComboBox that auto-scrolls to the top of the list whenever a user reaches the end of the list? I'd rather that the list stayed at the end and the user have to manually scroll back to the top.
Heres the XAML for the ComboBox:
<ComboBox x:Name="CellProviderCombo" HorizontalAlignment="Left" Height="65" Margin="14,405,0,0" VerticalAlignment="Top" Width=" 327" Header="Cell Provider" PlaceholderText="Choose Cell Provider" DataContext="{StaticResource GlobalVars}" ItemsSource="{Binding GlobalShopInfo.CellProviders}" DisplayMemberPath="Name" SelectedValuePath="Name" IsDoubleTapEnabled="False"/>
As I said, if you scroll past the last element in the combobox it simply starts over at the bottom and the scroll bar shoots back up to the top automatically.
Turns out that the ComboBox in WPF is not the same ComboBox used in Windows Apps Windows.UI.Xaml.
The ComboBox used in Windows Apps uses a Carousel instead of a StackPanel to display its items. One of the effects this has is making it so when you reach the end of the list, it simply loops back to the top. The solution is to manually change the ItemsPanelTemplate to a StackPanel as follows:
<ComboBox x:Name="MyComboBox"> //Add other properties in this line as well if needed
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
Hope this helps anyone who has a similar issue.
I have ListView with dependency property for selecting more than one item. ListView sample code is here:
<ListView ItemsSource="{Binding Test}"
ItemTemplate="{StaticResource SomeTemplate}"
SelectionMode="Multiple"
multipleBind:SelectionChangedCommand.Command="{Binding SelectionChangedCommand}">
</ListView>
It works properly but what I want is pre-select default items and I don't know How do it. Is it a possible? Please give me some hit.
Thanks
I have a Grouped Items Page created from VS11 template. This page has a GridView for normal view and a ListView that is shown when the page is snapped. I need to implement Semantic Zoom and still be able to snap the page.
I tried moving the GridView SemanticZoom.ZoomedInView so I have
<ScrollViewer x:Name="itemListScrollViewer" ...
<Listview ...
</ScrollViewer>
<SemanticZoom Grid.Row="1" >
<SemanticZoom.ZoomedInView>
<GridView ...
</SemanticZoom.ZoomedInView>
</SemanticZoom>
When the page is not snapped the ListView is hidden and when the page is snapped the gridView is hidden. The problem is that in snapped view the ListBox does not scroll and does not react to item clicks.
Do you want the snapped view to also have semantic zoom? In those cases, what I have done is implement two different SemanticZooms, one for landscape and one for snapped, and then showed only the correct one for current visual state. So starting point would be this:
<SemanticZoom x:Name="semanticZoom" Visibility="Visible">
<SemanticZoom.ZoomedOutView>
<GridView ...
</SemanticZoom.ZoomedOutView>
<SemanticZoom.ZoomedInView>
<GridView ...
</SemanticZoom.ZoomedInView>
</SemanticZoom>
<SemanticZoom x:Name="semanticZoomSnapped" Visibility="Collapsed">
<SemanticZoom.ZoomedOutView>
<ListView ...
</SemanticZoom.ZoomedOutView>
<SemanticZoom.ZoomedInView>
<ListView ...
</SemanticZoom.ZoomedInView>
</SemanticZoom>
Or if you don't need semantic zoom in the snapped mode, just try your current approach but try hiding the SemanticZoom element instead of the GridView inside it. And of course make sure that ListView's isItemClickEnabled is set to true etc.
P.S. I suppose where you say ListBox you mean ListView? Since an element called ListBox also exists.
I found a very strange way to fix the problem. When I switch the ordet of SemanticZoom an ScrollViewer like
<SemanticZoom Grid.Row="1" >
<SemanticZoom.ZoomedInView>
<GridView ...
</SemanticZoom.ZoomedInView>
</SemanticZoom>
<ScrollViewer x:Name="itemListScrollViewer" ...
<Listview ...
</ScrollViewer>
Than everything works. Any idea why?