How to adjust screen when keyboard open in windows phone 8? - c#

I am working in Windows phone 8. In One of the pages of my app there is a LongListSelector and under it there is a TextBox. When the TextBox get focused then keyboard is opened. As the keyboard is opened then the LongListSelector is shifted up by keyboard height. If I maintain the margin of the LongListSelector by keyboard's offset then some of the items of LongListSelector go under the keyboard.
All I want to do is when keyboard is shown then margin will be updated and the previous focused item of the LongListSelector should not go under keyboard. Here I don't want to use ScrollTo() function to scroll a specific item of LongListSelector.
Any suggestion or help will be appreciated.

Here is an example of workaround. Though this code is for WP8. You will have to make some changes to make this working for WP8.1 like :
Tap in xaml will be replaced by Tapped.
((App)Application.Current).RootFrame.RenderTransform = new CompositeTransform();
will be replaced by
Window.Current.Content.RenderTransform = new CompositeTransform();
Dispatcher.BeginInvoke(() => {}will be replaced by
CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{}
let me know if you face any issue.

Related

How to prevent auto closing of soft input panel in UWP?

I am facing an unexpected behavior of Keyboard showing and hiding in UWP app working on tablet with windows 10.
After carefully testing again and again i noticed that this issue comes when you have focus on input box and keyboard is opened for it. Now focusing next input needs layout adjustment so that it should not be hidden by keyboard. When you try to focus next element, by default previously opened keyboard hides and now i'm not able to open keyboard un till this new input box lose focus and manually gain focus again.
So for controlling this issue i want to prevent automatic hide and show of keyboard every time i switch focus to new textbox. It should open keyboard once the page load (already found solution using InputPane) and hiding should only be by clicking cancel (x) button.
Please check this video for clearly understanding the issue.
https://www.dropbox.com/s/1c876uwytywio1t/Soft%20Keyboard%20Issue.mp4?dl=0
Please vote this suggestion if anyone else is also facing this issue.
https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/34170142-inputpane-does-not-open-when-focus-is-shifted-to-n
This issue has been partially resolved in windows 10 version 1803 released on 30th April, 2018. In this version InputPane does not hide and show again and again when focus is shifted from one input element to other.
You may try to put a horizontal-stretched placeholder control (let say, StackPanel) at the bottom of your page, then let it the same size the on-screen keyboard does. That could prevent uncontrolled auto-hide trigger being fired (at least I did that trick on UWP mobile app):
// on the window initialization, remember the input pane
this._inputPane = InputPane.GetForCurrentView()
// then, subscribe to the events
_inputPane.Showing = (sender, args) =>
{
args.EnsuredFocusedElementInView = true; // skip default vertical-shift behavior
this._placeholderPane.Height = args.OccludedRect.Height;
}
_inputPane.Hiding = (sender, args) =>
{
this._placeholderPane.Height = 0;
}
Hope it helps on the Win10 desktop same way as it was on mobile one.
P.S. Yes, initially the placeholder pane is zero-height and collapsed.

WP8.1 Navigation Bar Overlay

I am currently developing an application in windows phone 8.1 And I am having problems with the soft system navigation bar.
I can hide the bar, but I can't seem to find if it is visible or not.
To hide it, I could use:
ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
The problem is that some phones have it, some don't. I need to find if it is active so that I can bind the height of my VirtualizingStackPanel correctly.
Thank you,
As far as i know there is no perfect way to work with the none-hardware nav bar, and i think that your best option here is to subscribe to the ApplicationView.VisibleBoundsChanged event,
so basically what you need to do is :
set the ApplicationViewBoundsMode to UseCoreWindow so that the content will be laid out in the region occupied by the core phone window :
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
subscribe to the VisibleBoundsChanged event and handle you UI changes inside the handler:
ApplicationView.GetForCurrentView().VisibleBoundsChanged += handler;
//...
private void handler(ApplicationView sender, object args)
{
//handle ui changes
}

How to create a login popup window similar to Windows 10 Sports App which is movable?

I tried to make a similar login pop up window using PopUp, MessageDialog and ContentDialog. But none of them satisfied my requirement. Please tell me how to achieve a similar popup window which has textbox and buttons in it using XAML or C# for building Windows Universal App.
Thank you in advance !
Pls see the box here. It is movable by mouse dragging also:
http://postimg.org/image/ucjm8hsk5/
You could achieve the dragging feature by using the Manipulation events and the Projection property.
I suggest you to use a Border that will contain all of your controls (in a Grid inside your Border for example) and set the ManipulationMode property to All.
Then attach a method to the ManipulationDelta event of your Border with the following code:
private void Border_OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
var border = (Border)sender;
var currentProjection = border.Projection as PlaneProjection ?? new PlaneProjection();
border.Projection = new PlaneProjection() { GlobalOffsetX = currentProjection.GlobalOffsetX + e.Delta.Translation.X, GlobalOffsetY = currentProjection.GlobalOffsetY + e.Delta.Translation.Y };
}

Listbox jumps to top when resuming scroll from last position

(Windows Phone 8.1) In my app, I have a MainPage with a listbox. NavigationCacheMode is set to required to preserve the state when navigating back to the same page.
public MainPage()
{
this.InitializeComponent();
this.DataContext = this;
// cache page
this.NavigationCacheMode = NavigationCacheMode.Required;
}
So when I go to another page and come back to my MainPage everthing looks the same as I left it. The Listbox is also in the corrent position. But whenever I touch it, it will jump to the top before it scrolls...
How can I make it so that it resumes scrolling before going to the top first?
EDIT: solved
Seems like Listbox is bugged in WP8.1, use ListView instead!
I had the same problem and figured out that it's primarily the chosen ItemsPanelTemplate which causes the Bug.
When using a ListView, the standard ItemsPanelTemplate is ItemsStackPanel, which works fine. If you change that to VirtualizingStackPanel (standard for ListBox) the bug appears. But only on Windows Phone, for Windows it works like expected.
So I assume that, when you like to use ListBox instead of ListView, you have to use ItemStackPanel as ItemsPanelTemplate to preserve the scroll position via NavigationCacheMode.

How can I disable the virtual keyboard for all my WPF apps?

I saw method to do this for current control but I need to do it for all app. I have touch scren and when i click on some textbox virtual keyboard from windows 7 shown. I don't need it because i how own keyboard in program.
Please help.
Thanks.
Not sure if you got an answer in the few months the question was online, but this worked for me.
First, you need a reference to Microsoft.Ink.dll.
var handle = new WindowInteropHelper(this).Handle;
TextInputPanel panel = new TextInputPanel(handle);
panel.InPlaceVisibleOnFocus = false;
That first line gets a Handle to the window of your app, and then you just need to create the TextInputPanel object and set it's InPlaceVisibleFocus to false. This will no longer show the TIP icon when a textbox is touched.

Categories

Resources