[DatePickerTextBox] how to remove white line around the date

Jul 3, 2009 at 2:42 AM

hello

is there any way to remove the white line around the date in the datepickertextbox?

screenshot:

http://www.shareapic.com/public/view/full/41776

as u may notice there's a white line around the text inside the textbox, how can i remove that?

 

thanks,

sando

Jul 9, 2009 at 3:36 AM

still no respond?

 

T__T

Jul 10, 2009 at 8:44 AM

just bumping this question O__O

 i really need help here

Jul 10, 2009 at 11:40 AM

Hi,

Just set BorderThickness="0"

But I must say, judging from the screenshot you uploaded, I think it looks like you are building some web component. It doesn't look like you're using the WPF Toolkit DatePicker at least...

Jul 13, 2009 at 3:32 AM

Hi, 

thanks for the respond, but BorderThickness affect the black border around the textbox not the white line,

and i'm using wpftoolkit datepicker but i retemplate it so i can use the calendar icon instead the default image

 

 

this is how i retemplate the datepicker

<Style x:Key="DatePicker_Standard" TargetType="{x:Type Toolkit:DatePicker}">
        <Setter Property="Control.FontFamily" Value="/#Calibri" />
        <Setter Property="Control.FontSize" Value="12" />
        <Setter Property="Control.Margin" Value="2" />
        <Setter Property="Control.Height" Value="21" />
        <Setter Property="Control.VerticalAlignment" Value="Center" />
        <Setter Property="ToolkitPrimitives:DatePickerTextBox.BorderBrush" Value="{StaticResource SolidBorderBrush}"/>
        <Setter Property="Toolkit:DatePicker.BorderThickness" Value="0"/>
        <Setter Property="Toolkit:DatePicker.DisplayDateStart" Value="1753-01-01"/>
        
          <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Toolkit:DatePicker}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            ContextMenu="{x:Null}"
                            Padding="{TemplateBinding Padding}">
                        <Border.Child>
                            <Grid x:Name="PART_Root"
                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                <Grid.Resources >
                                    <!-- Button Template -->
                                    <ControlTemplate x:Key="DropDownButtonTemplate" TargetType="Button">                                       
                                        <Image Style="{DynamicResource imageCalendarDatePicker}" Height="20" Width="20" />                                        
                                    </ControlTemplate>                                   
                                    
                                </Grid.Resources>                                
                                
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Button x:Name="PART_Button" Grid.Row="0" Grid.Column="1"
                                        Template="{StaticResource DropDownButtonTemplate}"
                                        Foreground="{TemplateBinding Foreground}"
                                        Width="20"
                                        Margin="3,0,3,0"
                                        Focusable="False"
                                        VerticalAlignment="Top"
                                        HorizontalAlignment="Left" />
                                <ToolkitPrimitives:DatePickerTextBox x:Name="PART_TextBox"   
                                                                     BorderThickness="1" HorizontalContentAlignment="Stretch"
                                                                     VerticalContentAlignment="Stretch"
                                                                     Foreground="{TemplateBinding Foreground}"
                                                                     Grid.Row="0" Grid.Column="0"  
                                                                     Background="White"                         
                                                                     Padding="0"
                                                                     BorderBrush="{TemplateBinding BorderBrush}">
                                    
                                    <ToolkitPrimitives:DatePickerTextBox.ContextMenu>
                                        <ContextMenu Visibility="Hidden"/>
                                    </ToolkitPrimitives:DatePickerTextBox.ContextMenu>                                    
                                </ToolkitPrimitives:DatePickerTextBox>

                                <Grid x:Name="PART_DisabledVisual"
                                      Opacity="0"
                                      IsHitTestVisible="False"
                                      Grid.Row="0" Grid.Column="0"
                                      Grid.ColumnSpan="2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Rectangle Grid.Row="0" Grid.Column="0" RadiusX="1" RadiusY="1" Fill="{StaticResource SolidBorderBrush}"/>
                                    <!--<Rectangle Grid.Row="0" Grid.Column="1" RadiusX="1" RadiusY="1" Fill="{StaticResource SolidBorderBrush}" Height="18" Width="19" Margin="3,0,3,0" />-->
                                    <Popup x:Name="PART_Popup"
                                           PlacementTarget="{Binding ElementName=PART_Button}"
                                           Placement="Bottom"
                                           StaysOpen="False"
                                           AllowsTransparency="True" />
                                </Grid>
                            </Grid>
                        </Border.Child>
                    </Border>
                    <ControlTemplate.Triggers>
          <Trigger Property="IsEnabled" Value="False">
            <Setter TargetName="PART_TextBox" Property="Background" Value="{StaticResource DisabledBackgroundBrush}"/>
            <Setter TargetName="PART_TextBox" Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            <Setter TargetName="PART_TextBox" Property="BorderBrush" Value="{StaticResource SolidBorderBrush}"/>
          </Trigger>
        </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Coordinator
Jul 22, 2009 at 1:03 AM

Hi Sando -

Assuming that screenshot is of your Disabled DatePicker, then I think you want to set Border="0" on your DatePickerTextBox. Let me know if that doesn't seem to solve your issue.

-Eric, MSFT

Jul 22, 2009 at 8:19 AM

hi eric,

thanks for the respond but unfortunately it's not solved the problem, the Border on DatepickerTextBox refer to the black border around it.

below i provide the screenshot if i set it like this:

<ToolkitPrimitives:DatePickerTextBox x:Name="PART_TextBox"   
                                                                    BorderThickness="0"

http://www.shareapic.com/public/view/43372

 

u can see that the white line is still there x___x

owh yeah, i forgot to remove the property HorizontalContentAlignment="Stretch", if i remove this and make the field empty, then it will be like this:

http://www.shareapic.com/public/view/43375

 

as u can see, i think the whit line has nothing to do with border, CMIIW

 

regards,

sando

 

Coordinator
Jul 22, 2009 at 8:29 PM

Hi Sando -

I think I see what you are talking about. You may have to modify the ControlTemplate of the DatePickerTextBox. In that template you will see a Grid called WatermarkContent. In this Grid the first two children should be Borders hardcoded to be 1px and white (#FFFFFFFF). When the Control is moused over the VSM code animates them blue. The white border you want to remove (should) consist of these two overlayed 1px white (when not moused over) Borders. I'd suggest setting the Borders' Color to Transparent (which should show the Background of the Control) or you can TempalteBind it to the TextBox's Background. Let me know if this works out for you.  If not, we can try again :-P

-Eric, MSFT

Jul 23, 2009 at 4:10 AM

yay ^o^

it works ^_^, thanks eric, i have to remove the content property from this code though

<ContentControl x:Name="PART_Watermark"
                                                        Opacity="0"
                                                        Focusable="False"
                                                        IsHitTestVisible="False"
                                                        Content="{TemplateBinding Watermark}"             <--- this one
                                                        Padding="2"/>

i dunno why, but i can't run my program if use that part of code lol

 

-sando-

Coordinator
Jul 23, 2009 at 8:20 PM

Hi Sando -

You need to edit that line because you are referencing the Watermark property, which is marked as internal inside the DatePickerTextBox which restricts access it. Remove the TemplateBinding and enter whatever text you would like to see as your Watermark. Note: without any additional logic/xaml, your watermark will remain the same regardless of what DateFormat is set (Short, Long).

-Eric, MSFT

Jul 24, 2009 at 6:07 AM

Hi eric,

ahh i see now why it's created an error, but i think in my current application i don't need the watermark, so it won't be any problem if i don't use it lol.

well i guess next time i need to retemplate it from the start then build the newer dll and not get the dll then retemplate it lol

 

well thanks for the help anyway ^__^

 

sando