Ask a questionAsk a question
 

AnswerPasswordBox with round corner???

  • Friday, April 20, 2007 5:05 PMPlaTyPuS8 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi!

     

    is it possible to have rounded corner in a PasswordBox?? I search to make it in blend but don't find the property that allows me to do that....

     

    Here is a copy of the PasswordBox style :

    Code Snippet

      <Style x:Key="PasswordBoxStyle1" TargetType="{x:Type PasswordBox}">
       <Setter Property="FontFamily" Value="/Resources/#EUROSTILE"/>
       <Setter Property="PasswordChar" Value="●"/>
       <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
       <Setter Property="BorderThickness" Value="1"/>
       <Setter Property="HorizontalContentAlignment" Value="Left"/>
       <Setter Property="Padding" Value="1"/>
       <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
       <Setter Property="AllowDrop" Value="true"/>
       <Setter Property="Template">
        <Setter.Value>
         <ControlTemplate TargetType="{x:Type PasswordBox}">
          <Microsoft_Windows_Themes:ListBoxChrome SnapsToDevicePixels="true" x:Name="Bd" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" OpacityMask="{x:Null}">
           <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" Template="{DynamicResource ScrollViewerControlTemplate1}"/>
          </Microsoft_Windows_Themes:ListBoxChrome>
          <ControlTemplate.Triggers>
           <Trigger Property="IsEnabled" Value="false">
            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
           </Trigger>
          </ControlTemplate.Triggers>
         </ControlTemplate>
        </Setter.Value>
       </Setter>
      </Style>

     

    Thx for help ;-)

     

    ++

Answers

  • Friday, April 20, 2007 5:36 PMMatt Hohn - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    if this is a Border [ Microsoft_Windows_Themes:ListBoxChrome ] , you should be able to set the CornerRadius property on it..
  • Friday, April 20, 2007 5:57 PMTamir Khason Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This style if working for me

     

    Code Snippet

    <Style TargetType="PasswordBox">

    <Setter Property="PasswordChar" Value=""/>

    <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>

    <Setter Property="BorderThickness" Value="1"/>

    <Setter Property="HorizontalContentAlignment" Value="Left"/>

    <Setter Property="Padding" Value="1"/>

    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>

    <Setter Property="AllowDrop" Value="true"/>

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="PasswordBox">

    <Border CornerRadius="5" x:Name="Bd" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="Black" BorderThickness="1" OpacityMask="{x:Null}">

    <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" Template="{DynamicResource ScrollViewerControlTemplate1}"/>

    </Border>

    <ControlTemplate.Triggers>

    <Trigger Property="IsEnabled" Value="false">

    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>

    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>

    </Trigger>

    </ControlTemplate.Triggers>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

     

  • Friday, April 20, 2007 6:11 PMPlaTyPuS8 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    I don't know what [ Microsoft_Windows_Themes:ListBoxChrome ] is... but I change it with Border and I can yet set CornerRadius on it .

     

    Thanks for your fast answers.
     
    ++

All Replies

  • Friday, April 20, 2007 5:36 PMMatt Hohn - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    if this is a Border [ Microsoft_Windows_Themes:ListBoxChrome ] , you should be able to set the CornerRadius property on it..
  • Friday, April 20, 2007 5:57 PMTamir Khason Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This style if working for me

     

    Code Snippet

    <Style TargetType="PasswordBox">

    <Setter Property="PasswordChar" Value=""/>

    <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>

    <Setter Property="BorderThickness" Value="1"/>

    <Setter Property="HorizontalContentAlignment" Value="Left"/>

    <Setter Property="Padding" Value="1"/>

    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>

    <Setter Property="AllowDrop" Value="true"/>

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="PasswordBox">

    <Border CornerRadius="5" x:Name="Bd" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="Black" BorderThickness="1" OpacityMask="{x:Null}">

    <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" Template="{DynamicResource ScrollViewerControlTemplate1}"/>

    </Border>

    <ControlTemplate.Triggers>

    <Trigger Property="IsEnabled" Value="false">

    <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>

    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>

    </Trigger>

    </ControlTemplate.Triggers>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

     

  • Friday, April 20, 2007 6:11 PMPlaTyPuS8 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    I don't know what [ Microsoft_Windows_Themes:ListBoxChrome ] is... but I change it with Border and I can yet set CornerRadius on it .

     

    Thanks for your fast answers.
     
    ++
  • Friday, April 20, 2007 7:15 PMPlaTyPuS8 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    re

     

    do you know how I can make an effect like in InfoTextBox (Microsoft.Samples.KMoore.WPFSamples.InfoTextBox) ?

     

    --> a text like "Enter a password here..." in the passwordbox and when the user start to enter text in the passwordbox, this text disappear...

     

    I tried with trigger, but it doesn't work...

     

    thxxx

  • Friday, April 20, 2007 7:53 PMnetisfun_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Couldn't you just put a label control over top of the content and then set a trigger to fade it out?
  • Friday, April 20, 2007 8:12 PMPlaTyPuS8 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     GC wrote:
    Couldn't you just put a label control over top of the content and then set a trigger to fade it out?

     

    yes, I already tried it, but what event should I use to fade it out and remove the effect?

     

  • Friday, April 09, 2010 4:15 AMRagnar Roos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Looking at the source code for the ListBoxChrome found in the PresentationFramework.Aero.dll, it would seem impossible to affect the default rounding of 1.0 pixels since this is what's being rendered with hard coded values.

    Further, substituting the ListBoxChrome for a border effetively disables the default animation for focused and mouse over which is present in the ListBoxChrome of the TextBox/PasswordBox.

    I've yet to come up with anything truly functional apart from duplicating the entire ListBoxChrome functionality and adding support for setting the X and Y radii values through normal DP behavior.


    Ragnar Roos