progress ring in xaml not preventing the game pad controller action? - xaml

I have implemented the uwp loader in my xaml page to prevent the user interaction.
<ProgressRing x:Name="loader" Width="70" Height="70" Foreground="White"/>
but the problem is controller actions still working which allows the user interactions.Is there any possibility for preventing the controller actions while the loader is working?

Progress ring is only a visual indicator for user that there is some longer action taking place. It does not prevent him from doing anything.
You are too unspecific with your question, but there are many ways of suppressing user input depending on your aproach to handling gamepad.
You can, for example set IsEnabled attribute for the whole page to false (works only for XAML elements).
You can detach event handlers for keydown event.
Or you can create a boolean variable (e.g. canplay) which you set to to false whenever you want to suppress user input, and in the function when you processing gamepad buttons you can check its value:
if (canplay)
{
//process gamepad buttons
}

Related

TextBox gaining unwanted focus

I have a simple xaml page with one TextBox and a RichTextBlock.
Inside that RichTextBlock there are some InlineUIContainers.
But when the user presses a button, I remove through code an InlineUIContainer. This goes well, but each time this is done, the TextBox that is on the page get's focus!
Resulting in the touch keyboard popping up. Anyone an idea why this is happening? Or how I can prevent this?
I can't set the IsTabStop, because the user still has to be able to fill something in if needed.
I'm working on the Windows Phone part of a WinRT Universal app
Some code, but the actual removal is done in the Attached Dependency Property
It's the KeywordsInput textbox that get's the focus after each removal
<TextBox x:Uid="Search_KeywordsInput" x:Name="SearchKeywordsInput"
Text="{Binding KeywordsInput, Mode=TwoWay}" />
<RichTextBlock Grid.Row="4"
Margin="0,9.5,0,0"
IsTextSelectionEnabled="False"
dependencyProperties:RichTextBlockTagCloud.Command="{Binding SelectedTagFilterCommand}"
dependencyProperties:RichTextBlockTagCloud.TagItems="{Binding SelectedFilters, Mode=TwoWay}">
<Paragraph x:Name="TagsFilters" />
foreach (InlineUIContainer container in buttonsToRemove)
tagParagraph.Inlines.Remove(container);
Have you try to set IsTabStop=False on Button, so clicking button doesn't steal RichTextBox focus.
If you remove the focused control then the focus will move to a valid control. In this case, the next control found is your TextBox. If you park the focus on a benign (non-text) control before removing the focussed button then the keyboard won't trigger.
Depending on your overall layout you may be able to set the focus to the page, you may have another button which would make sense, or you could add a non-editable control to the tab order.

Durandal modal dialog position issue when content added after initial display

I display a modal dialog with a small "please wait" message whilst an Ajax request is underway. Once that request is finished, the result is injected into the content of the modal dialog. If it is significantly larger, obviously the size calculations are thrown off and the "OK" button disappears off the bottom of the screen, requiring a reload to clear the modal!
Is there anything that can be done to resize/reposition the modal dialog after I inject the new content into it, or do I need to change my logic to show a "please wait" and then close it and display the new modal dialog in its completed state?
If you wish to take over the repositioning logic of a Durandal dialog, you would create a custom dialog context. Place your repositioning logic inside of the compositionComplete handler.
Resize, on the other hand, can be handled strictly with CSS. But it can be handled in the compositionComplete handler of the custom dialog context as well.
We have written several custom dialog contexts, and use the approach above to achieve what you are trying to achieve. We have even gone so far as to include special animations in the compositionComplete handler.
Take a look here in Durandal's documentation.
Also, I have uploaded to my public OneDrive a short movie of one of our custom dialog contexts. You can view it here. The slide-out window that pops in front is actually a custom Durandal dialog context.
In Durandal 2.1.0, there will be a method to to reposition the dialog. See:
https://github.com/BlueSpire/Durandal/blob/Version-2.1.0/docs/2.x/Showing-Message-Boxes-And-Modals.html.md#repositioning-dialogs-after-their-contents-have-been-changed

How to trigger a storyboard on a list item when it is tapped and have the page be notified when the animation ends?

I'm porting a Windows Phone 8 app to Windows 8 and I have a scenario where the user taps an item in my list control / grid view and I want to play an "activation" animation on the item, wait for the animation to complete, and then navigate away from the page.
On Windows Phone, I used DataTriggers in one case, and in another I used VisualTreeHelper to iterate through the view and find the VirtualizingStackPanel and then the actual item and then accessed it directly to invoke the storyboard...
Neither appears to work in this case and also seems that DataTriggers are not supported in winrt (DataTrigger in WinRT?).
I'd like to do the right thing here. I've seen suggestions that visual states can be used, but it is not clear how in this case.
Any help much appreciated.
Thanks
There are two ways I would go about this, though neither is particularly pretty.
Method A
Create a custom control that will act as each GridView item and place it in the GridView's ItemTemplate.
<GridView>
<GridView.ItemTemplate>
<DataTemplate>
<mynamespace:MyControl/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
Then, in MyControl's constructor, attach a handler to the Tapped event, and in that handler you can perform your animation. The animation can be defined in MyControl.xaml. MyControl should also expose an event for when the animation is complete
public event EventHandler SelectedAnimationComplete;
and fire it when your custom storyboard completes. The page hosting the GridView can attach to MyControl's custom event to perform the navigation.
...
<mynamespace:MyControl SelectedAnimationComplete="selectedAnimationComplete"/>
...
Method B
On the GridView, set SelectionMode to None, IsItemClickEnabled to true, and attach a handler to the ItemClick event. Inside the handler, you can use
(sender as GridView).ItemContainerGenerator.ContainerFromItem(e.ClickedItem)
to get the GridViewItem, and then dig down the visual tree with VisualTreeHelper.GetChild. In your ItemTemplate, the root visual (likely a Grid) can have your animation placed in its Resources collection. Dig down the visual tree until you find the ItemTemplate's root grid, get the animation from its Resources collection, attach a completion handler to it, and run it. You can perform your navigation in the completion handler.

How to create toggle buttons in Windows 8?

I need to create a group of 5 buttons. Only one can be pressed, like Radio Button, but I do not want to show the circle. I would like to use the button look.
Somebody do know which is the best way to do it?
I have found for WPF:
<RadioButton Style="{StaticResource {x:Type ToggleButton}}" />
but it does not work for Windows 8.
Thank you
Is this a group of actual buttons with an action assigned to the click event of each, or are you just trying to remove the circle form a RadioButton type control?
Please note that the user will likely expect a RadioButton control to look and feel like a RadioButton. Changing this just for the sake of it may not be a good idea, but if you want to go ahead with it you could try one of the following options.
1) Edit the template for a radiobutton control to hide the selcetion circle. (I don't know if that's even possible in all honesty, but in theory, it should be)
or
2) Emulate the behaviour with a ListView with SelctionMode set to "Single"
Things get a little more complicated if you want to handle click events on each "button", but it is not impossible. In your ItemTemplate, add a button (presumable with a style of "TextButtonStyle") and set the event handler of the Click event to check which button was pressed and act accordingly.
There is a control called ToggleButton, why don't you use that?

Catch resizing of window in Silverlight Popup

I'm using a usercontrol with a popup element in it to create some kind of notification system.
There's the possibility that some notifications will be non-timed, so they stay open until the user interacts with it. This works allright, but when the user resizes the browser, the popup control has the wrong size.
I've tried catching the sizechanged on the usercontrol, but that doesn't get called (seems obvious now).
The one solution I have is catching the sizechanged on the mainwindow and applying it to the usercontrol. This notification usercontrol is singleton, so I can do it once and all notifications will have the right size. I just don't feel like this is the right solution.
Any other ideas on this matter?