zoukankan      html  css  js  c++  java
  • 《TextBox》软件键盘 SIP 的所有样式

    没有什么好讲的直接上代码,自己运行查看:

    一、定义个静态类

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Reflection;
     4 using System.Linq;
     5 
     6 namespace PhoneApp1
     7 {
     8     public static class Utilities
     9     {
    10         public static KeyValuePair<string, T>[] EnumValues<T>(this Type enumerationType)
    11         {
    12             var enumList = new List<KeyValuePair<string, T>>();
    13             if (enumerationType.BaseType == typeof(Enum))
    14             {
    15                 var fields = enumerationType.GetFields(BindingFlags.Public | BindingFlags.Static);
    16                 foreach (var field in fields)
    17                 {
    18                     var enumValue = field.GetValue(null);
    19                     if (((int)enumValue) > 0)
    20                     {
    21                         enumList.Add(new KeyValuePair<string, T>(enumValue.ToString(), (T)enumValue));
    22                     }
    23                 }
    24             }
    25             return enumList.OrderBy(kvp => kvp.Key).ToArray();
    26         }
    27     }
    28 }

    二、创建一个页面,输入下面代码运行

     1 <phone:PhoneApplicationPage 
     2     x:Class="PhoneApp1.SIPpage"
     3     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     4     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     5     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
     6     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
     7     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     8     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     9     FontFamily="{StaticResource PhoneFontFamilyNormal}"
    10     FontSize="{StaticResource PhoneFontSizeNormal}"
    11     Foreground="{StaticResource PhoneForegroundBrush}"
    12     SupportedOrientations="Portrait" Orientation="Portrait"
    13     mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    14     shell:SystemTray.IsVisible="True">
    15 
    16     <!--LayoutRoot is the root grid where all page content is placed-->
    17     <Grid x:Name="LayoutRoot" Background="Transparent">
    18         <Grid.RowDefinitions>
    19             <RowDefinition Height="Auto"/>
    20             <RowDefinition Height="*"/>
    21         </Grid.RowDefinitions>
    22 
    23         <!--TitlePanel contains the name of the application and page title-->
    24         <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
    25             <TextBlock x:Name="ApplicationTitle" Text="MY SIP" Style="{StaticResource PhoneTextNormalStyle}"/>
    26             <TextBlock x:Name="PageTitle" Text="SIP Learn" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    27         </StackPanel>
    28 
    29         <!--ContentPanel - place additional content here-->
    30         <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    31             <Grid.RowDefinitions>
    32                 <RowDefinition Height="*"/>
    33                 <RowDefinition Height="Auto"/>
    34             </Grid.RowDefinitions>
    35             <ListBox SelectionChanged="InputScopeList_SelectionChanged"  Height="Auto" Margin="10" Name="InputScopeList" VerticalAlignment="Top" BorderThickness="2" >
    36                 <ListBox.ItemTemplate>
    37                     <DataTemplate>
    38                         <TextBlock Text="{Binding Key}"/>
    39                     </DataTemplate>
    40                 </ListBox.ItemTemplate>
    41             </ListBox>
    42             <TextBox Height="96" Grid.Row="1" HorizontalAlignment="Left" Margin="10" Name="InputText" VerticalAlignment="Bottom" Width="435"/>
    43         </Grid>
    44     </Grid>
    45 </phone:PhoneApplicationPage>
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Net;
     5 using System.Windows;
     6 using System.Windows.Controls;
     7 using System.Windows.Documents;
     8 using System.Windows.Input;
     9 using System.Windows.Media;
    10 using System.Windows.Media.Animation;
    11 using System.Windows.Shapes;
    12 using Microsoft.Phone.Controls;
    13 
    14 namespace PhoneApp1
    15 {
    16     public partial class SIPpage : PhoneApplicationPage
    17     {
    18         public SIPpage()
    19         {
    20             InitializeComponent();
    21 
    22             this.Loaded += new RoutedEventHandler(SIPpage_Loaded);
    23         }
    24 
    25         void SIPpage_Loaded(object sender, RoutedEventArgs e)
    26         {
    27             this.InputScopeList.ItemsSource = typeof(InputScopeNameValue).EnumValues<InputScopeNameValue>();
    28         }
    29 
    30         private void InputScopeList_SelectionChanged(object sender, SelectionChangedEventArgs e)
    31         {
    32             if (this.InputScopeList.SelectedItem == null)
    33                 return;
    34             var selection = (KeyValuePair<string, InputScopeNameValue>)this.InputScopeList.SelectedItem;
    35             InputScope inputScope = new InputScope();
    36             inputScope.Names.Add(new InputScopeName() { NameValue = selection.Value });
    37             this.InputText.InputScope = inputScope;
    38         }
    39     }
    40 }
  • 相关阅读:
    IE6下不能定义1px高度的容器和IE6 双边距
    py django 渲染前端打包的视图
    关于常见的递推关系。
    题解:一些递推的题。
    题解:极值问题。
    题解:城南树林。
    题解:论编辑器的和谐共处。
    题解:左右横跳。
    题解:斑马,斑马(zebra)
    找 前端 私活
  • 原文地址:https://www.cnblogs.com/qq278360339/p/2517682.html
Copyright © 2011-2022 走看看