สร้างกล่องรหัสผ่านอีกครั้ง

ฉันกำลังทำงานกับ แอปพลิเคชัน Windows Phone 8 C#/XAML .NET 4.5 และฉันพยายามสร้างรูปแบบใหม่/จัดรูปแบบกล่องรหัสผ่าน แต่ถึงแม้ฉันจะมีความคิดทั่วไปว่าต้องทำอย่างไร แต่ฉันก็ยังทำได้ ไม่ได้ทำให้เสร็จตามความต้องการของฉัน

ปัญหา

สิ่งแรกที่ฉันต้องค้นหาคือเทมเพลต PasswordBox ที่เหมาะสมสำหรับ Windows Phone 8 ฉันพบ อันนี้[msdn] แต่มันใช้งานไม่ได้ และฉันไม่รู้ว่าจะต้องเปลี่ยนอย่างไร จึงเป็นเช่นนั้น

คำถาม

  • เทมเพลตนี้ใช่หรือไม่ จะเปลี่ยนยังไงให้ "ติด"

person mishan    schedule 17.01.2014    source แหล่งที่มา
comment
คุณสามารถเปลี่ยนทุกสิ่งที่คุณต้องการได้เมื่อคุณแก้ไขเทมเพลตที่คุณรู้จัก (คลิกขวาที่ส่วนควบคุมของคุณ) การใช้การผสมผสานจะง่ายขึ้น :)   -  person MatDev8    schedule 17.01.2014
comment
เข้าใจแล้ว ถ้าคุณเขียนเป็นคำตอบ ฉันจะให้ +1 และคำตอบที่ถูกต้องแก่คุณ   -  person mishan    schedule 17.01.2014


คำตอบ (1)


คุณล้มเหลวตรงไหน? คุณได้รับข้อผิดพลาดอะไรบ้างขณะทำงาน

ต่อไปนี้เป็นรูปแบบ Windows Phone 8 PasswordBox ฉันสร้างโดยใช้ Expression Blend

<Style x:Key="PasswordBoxStyle" TargetType="PasswordBox">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="SelectionForeground" Value="{StaticResource PhoneContrastBackgroundBrush}"/>
        <Setter Property="Padding" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="PasswordBox">
                    <Grid Background="Transparent">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="EnabledBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DisabledBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="EnabledBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxEditBackgroundBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="EnabledBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxEditBorderBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="EnabledBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{StaticResource PhoneTouchTargetOverhang}">
                            <Border x:Name="ContentElement" BorderThickness="0" Margin="{StaticResource PhonePasswordBoxInnerMargin}" Padding="{TemplateBinding Padding}"/>
                        </Border>
                        <Border x:Name="DisabledBorder" BorderBrush="{StaticResource PhoneDisabledBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Margin="{StaticResource PhoneTouchTargetOverhang}" Visibility="Collapsed">
                            <PasswordBox x:Name="DisabledContent" Background="Transparent" Foreground="{StaticResource PhoneDisabledBrush}" Password="{TemplateBinding Password}" PasswordChar="{TemplateBinding PasswordChar}" Template="{StaticResource PhoneDisabledPasswordBoxTemplate}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
person asitis    schedule 17.01.2014
comment
ฉันเป็นมือใหม่กับ WPF และ Windows Phone ดังนั้นฉันจึงไม่ค่อยมีความรู้เรื่องสไตล์มากนัก ไม่ต้องพูดถึงว่าจะหาเทมเพลตได้จากที่ไหน ขอบคุณสำหรับคำตอบ. ฉันได้รับแบบเดียวกันก่อนหน้านี้เล็กน้อยจากความคิดเห็น และพบวิธีในการรับเทมเพลตนี้ในที่ที่ฉันต้องการโดยใช้ Visual Studio :) - person mishan; 17.01.2014
comment
อันนี้ดีสำหรับการฝึกซ้อม geekchamp.com/ เคล็ดลับ/ - person asitis; 17.01.2014