使用C#WP7 / 8改变InputScope动态事件发生后 [英] WP7/8 changing InputScope dynamically after an event using C#

查看:178
本文介绍了使用C#WP7 / 8改变InputScope动态事件发生后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows Phone的应用程序,我一直想了好半天,当方向改变为横向让主文本框更改的InputScope(使键盘占用空间更在没有景观自动更正吧),然后再返回。

I'm making an app for Windows Phone, I've been trying for ages to get the InputScope of the main text box to change when the orientation is changed to landscape (so that the keyboard takes up less space in landscape without the autocorrect bar), and back again.

我试验了第二个文本框,并在改变方向时躲在别人,但这并没有工作,整齐的。 :P

I experimented with a second text box and hiding the others upon an orientation change, but this did not work neatly AT ALL. :P

尝试,因为我可能,我不能得到这个工作,并能找到没有办法改变的OrientationChangedEvent说法,这已经在改变工作很好地后InputScope值围绕方位页面元素的位置。

Try as I might I can't get this to work and can find no way to change the InputScope value after the OrientationChangedEvent argument, which has worked nicely in changing the position of the elements of the page around orientations.

我还是相当新的发展与C#和XAML应用程序,我希望有一个不错的简单的方法来设置!我的文本框的InputScope是一个你真棒人能告诉我

I'm still fairly new to developing apps with C# and XAML, and I hope there's a nice easy way to set the InputScope of my text box that one of you awesome people could show me!

- 编辑:这里是事件处理程序(可能不是正确的术语)对本页面应用程序,里面的一切有工作绝对没问题,但无论如何我尝试添加任何与InputScope不起作用:(

-EDIT : Here's the event handler (might not be the right term) for this page of the app, everything inside there works absolutely fine, but any way I try to add anything to do with InputScope does not work :(

private void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        if ((e.Orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
        {
            //Portrait
            PlaceholderText.FontSize = 29.333;
            PlaceholderText.Padding = new Thickness (0,0,0,0);
            MainTweet.FontSize = 29.333;
            MainTweet.Padding = new Thickness (12,8,12,8);
            Counter.Margin = new Thickness (0,212,28,0);
        }
        else
        {
            //Landscape
            PlaceholderText.FontSize = 23;
            PlaceholderText.Padding = new Thickness (8,0,0,0);
            MainTweet.FontSize = 22;
            MainTweet.Padding = new Thickness (16,8,180,0);
            Counter.Margin = new Thickness (0,-18,28,0);
        }
    }



MainTweet.Text是键盘的重点是文本框在默认情况下,当网页被更改为横向我很想能够从搜索InputScope更改为另一个,可能是URL。在目前的东西在里面很好地重新排列的时候,我很欣赏它可能看起来不很整洁...

MainTweet.Text is the textbox that the keyboard is focusing on by default, when the page is changed to landscape I'd love to be able to change this from the "Search" InputScope to another, probably "URL". The stuff currently in there rearranges elements on the page nicely when the orientation is changed, I appreciate it might not look that neat...

推荐答案

有多个定向状态枚举 - 不仅仅是纵向风景。下面的工作为我改变的范围(在Windows Phone 7.5模拟器):

There are multiple "orientation" states in the enumeration - not just Portrait and Landscape. The following worked for me to change the scope (on Windows Phone 7.5 emulator):

if (e.Orientation == PageOrientation.Landscape
    || e.Orientation == PageOrientation.LandscapeRight
    || e.Orientation == PageOrientation.LandscapeLeft)
{
    InputScope inputScope = new InputScope();
    InputScopeName inputScopeName = new InputScopeName();
    inputScopeName.NameValue= InputScopeNameValue.Url;
    inputScope.Names.Add(inputScopeName);
    textBox1.InputScope = inputScope;
}



所以你丢弃到 MainPage_OrientationChanged 事件处理程序。

这篇关于使用C#WP7 / 8改变InputScope动态事件发生后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆