MaskedEdit是一款自定义Silverlight输入控件,可限定输入规则,直接继承自TextBox控件。

界面截图:
Silverlight 4开源项目之:自定义输入控件MaskedEdit_32786

Xaml Code[code]<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:IC="clr-namespace:Silverlight.InputCtrl;assembly=Silverlight.InputCtrl"       
    mc:Ignorable="d"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:layoutPrimitivesToolkit="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit" x:Class="MaskedEditDemo.MainPage"
    xmlns:local="clr-namespace:MaskedEditDemo"
    Height="800" Width="540" >
    <UserControl.Resources>
        <local:MaskEditConvertNumbers x:Key="MaskEditConv" />
    </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="#FFFCFCFC" Margin="0">
                <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="260"/>
                        <ColumnDefinition Width="5"/>
                        <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                        <RowDefinition Height="72" />
                        <RowDefinition Height="72"/>
                        <RowDefinition Height="72"/>
                        <RowDefinition Height="72"/>
                        <RowDefinition Height="72"/>
                        <RowDefinition Height="72"/>
                        <RowDefinition Height="144"/>
                        <RowDefinition Height="*"  />
                </Grid.RowDefinitions>
                <TextBlock Text="Result in TextUnMasked  Property" TextWrapping="Wrap" FontWeight="Bold" Foreground="#FF0F7A01" FontSize="12" Margin="0,0,-10,0" Grid.ColumnSpan="2" Grid.Column="2" VerticalAlignment="Top" HorizontalAlignment="Center"/>
                <TextBlock x:Name="LblNumUnMask" TextWrapping="Wrap" FontWeight="Bold" Foreground="#FF0F7A01" FontSize="12" Margin="0,0,0,10" Grid.ColumnSpan="2" Grid.Column="2" VerticalAlignment="Bottom" />
                <TextBlock x:Name="LblTextUnMask" TextWrapping="Wrap" Foreground="#FF0F7A01" FontWeight="Bold" FontSize="12" Margin="0,0,0,10" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="2"/>
                <TextBlock x:Name="LblCusUnMask" TextWrapping="Wrap" Foreground="#FF0F7A01" FontWeight="Bold" FontSize="12" Margin="0,0,0,10" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Row="2" Grid.Column="2"/>
                <TextBlock x:Name="LblPrdUnMask" TextWrapping="Wrap" Foreground="#FF0F7A01" FontWeight="Bold" FontSize="12" Margin="0,0,0,10" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Row="3" Grid.Column="2"/>
                <TextBlock x:Name="LblUcaseUnMask" TextWrapping="Wrap" Foreground="#FF0F7A01" FontWeight="Bold" FontSize="12" Margin="0,0,0,10" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Row="4" Grid.Column="2"/>
                <TextBlock x:Name="LblCurrUnMask" Foreground="#FF0F7A01" FontSize="12" FontWeight="Bold" TextWrapping="Wrap" Margin="0,0,0,10" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Row="5" Grid.Column="2"/>
        <StackPanel Orientation="Vertical" Margin="5,0,0,10">
                        <TextBlock Margin="0,0,-15,0" Text="Number Mask = "99999999"" TextWrapping="Wrap" FontSize="12" FontWeight="Bold">
                                <TextBlock.Foreground>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FF1240DE" Offset="0"/>
                                                <GradientStop Color="#FF0A0B0C" Offset="1"/>
                                        </LinearGradientBrush>
                                </TextBlock.Foreground>
                        </TextBlock>
                        <TextBlock Text="Enter a number" TextWrapping="Wrap" FontSize="12"/>
                        <IC:MaskedEdit x:Name="MaskNum" Margin="0" TextWrapping="Wrap" Mask="99999999" FontSize="12" LostFocus="MaskNum_LostFocus"  Background="#FFECE8E8"/>
                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="5,0,0,10" Grid.Row="1">
                        <TextBlock Text="Text Mask = "R{A}(20)"" TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Margin="0">
                                <TextBlock.Foreground>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FF1240DE" Offset="0"/>
                                                <GradientStop Color="#FF0A0B0C" Offset="1"/>
                                        </LinearGradientBrush>
                                </TextBlock.Foreground>
                        </TextBlock>
                        <TextBlock Text="Enter a Text (A-Z)" TextWrapping="Wrap" FontSize="12"/>
                        <IC:MaskedEdit x:Name="MaskText" TextWrapping="Wrap" Mask="R{A}(20)" FontSize="12" LostFocus="MaskText_LostFocus" Background="#FFECE8E8" Margin="0"/>
                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="5,0,0,10" Grid.Row="2">
                        <TextBlock Text="Custom Mask = "R{C}(10)"" TextWrapping="Wrap" FontSize="12" FontWeight="Bold" VerticalAlignment="Top" Margin="0">
                                <TextBlock.Foreground>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FF1240DE" Offset="0"/>
                               
all wife cheat site how to catch a cheater
TOP