Skip to main content

Microsoft Silverlight

Answered Question Beta2: Border shows around TextBox...RSS Feed

(0)

BenHayat
BenHayat

Participant

Participant

1033 points

600 Posts

Beta2: Border shows around TextBox...

Up to Beta 1, I had used TextBox to show multiple line texts and I had set the border to zero and color to NONE. Now as of beta 2 I get a border. How can I delete that border? Or is this a bug or feature?

___________
Best Regards;
..Ben

Silverlight & WPF Insider
Please visit www.MicroIntelligence.Com For our services!

Mark Rideout
Mark Rid...

Contributor

Contributor

2357 points

273 Posts

MicrosoftModerator
Answered Question

Re: Beta2: Border shows around TextBox...

The new visual style for TextBox uses gradients inside a Grid. This default style ignores the border thickness and border brush.
To remove the border you'll need to replace the tempalte. You can use Expression Blend to modify the template (this is the easiest way).
Here is what the default template looks like:

Single Line
        <ControlTemplate
            xmlns="
http://schemas.microsoft.com/client/2007"
            xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml">
            <Grid x:Name="RootElement">
                <Grid.Resources>
                    <SolidColorBrush x:Key="Background" Color="#FF003255"/>
       
                    <SolidColorBrush x:Key="BorderBrush" Color="#FF000000"/>
                    <SolidColorBrush x:Key="AccentBrush" Color="#FFFFFFFF"/>
       
                    <LinearGradientBrush x:Key="FocusedStrokeBrush"
                     StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="#B2FFFFFF" Offset="0"/>
                        <GradientStop Color="#51FFFFFF" Offset="1"/>
                        <GradientStop Color="#66FFFFFF" Offset="0.325"/>
                        <GradientStop Color="#1EFFFFFF" Offset="0.325"/>
                    </LinearGradientBrush>
       
                    <Storyboard x:Key="Normal State">
                        <DoubleAnimation Storyboard.TargetName="FocusVisualElement"
                         Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.0"/>
                    </Storyboard>
       
                    <Storyboard x:Key="Focused State">
                        <DoubleAnimation Storyboard.TargetName="FocusVisualElement"
                         Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.0"/>
                    </Storyboard>
                </Grid.Resources>
       
                <Rectangle StrokeThickness=".5" RadiusX="2"
                 RadiusY="2" Fill="{TemplateBinding Background}"/>
       
                <Rectangle StrokeThickness=".5" RadiusX="2" RadiusY="2" Stroke="#FF003255"/>
                <Border x:Name="ContentElement" Padding="{TemplateBinding Padding}"/>
       
                <Grid x:Name="FocusVisualElement" Opacity="0" IsHitTestVisible="False">
                    <Rectangle RadiusX="1" RadiusY="1" Margin="2"
                     Stroke="{StaticResource AccentBrush}" StrokeThickness="1"/>
                    <Rectangle RadiusX="1" RadiusY="1"
                     Stroke="{StaticResource Background}" StrokeThickness="2"/>
                    <Rectangle RadiusX="1" RadiusY="1"
                     Stroke="{StaticResource FocusedStrokeBrush}" StrokeThickness="2"/>
                </Grid>
            </Grid>
        </ControlTemplate>
 
MultiLine
        <ControlTemplate
            xmlns="
http://schemas.microsoft.com/client/2007"
            xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml">
            <Grid x:Name="RootElement">
                <Grid.Resources>
                    <SolidColorBrush x:Key="Background" Color="#FF003255"/>
       
                    <SolidColorBrush x:Key="BorderBrush" Color="#FF000000"/>
                    <SolidColorBrush x:Key="AccentBrush" Color="#FFFFFFFF"/>
       
                    <LinearGradientBrush x:Key="FocusedStrokeBrush"
                     StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="#B2FFFFFF" Offset="0"/>
                        <GradientStop Color="#51FFFFFF" Offset="1"/>
                        <GradientStop Color="#66FFFFFF" Offset="0.325"/>
                        <GradientStop Color="#1EFFFFFF" Offset="0.325"/>
                    </LinearGradientBrush>
       
                    <Storyboard x:Key="Normal State">
                        <DoubleAnimation Storyboard.TargetName="FocusVisualElement"
                         Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.0"/>
                    </Storyboard>
       
                    <Storyboard x:Key="Focused State">
                        <DoubleAnimation Storyboard.TargetName="FocusVisualElement"
                         Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.0"/>
                    </Storyboard>
                </Grid.Resources>
       
                <Rectangle StrokeThickness=".5" RadiusX="2"
                 RadiusY="2" Fill="{TemplateBinding Background}"/>
       
                <Rectangle StrokeThickness=".5" RadiusX="2" RadiusY="2" Stroke="#FF003255"/>
                <ScrollViewer x:Name="ContentElement" Padding="{TemplateBinding Padding}"/>
       
                <Grid x:Name="FocusVisualElement" Opacity="0" IsHitTestVisible="False">
                    <Rectangle RadiusX="1" RadiusY="1" Margin="2"
                     Stroke="{StaticResource AccentBrush}" StrokeThickness="1"/>
                    <Rectangle RadiusX="1" RadiusY="1"
                     Stroke="{StaticResource Background}" StrokeThickness="2"/>
                    <Rectangle RadiusX="1" RadiusY="1"
                     Stroke="{StaticResource FocusedStrokeBrush}" StrokeThickness="2"/>
                </Grid>
            </Grid>
        </ControlTemplate>


Thanks,
-mark
Silverlight Program Manager

 

BenHayat
BenHayat

Participant

Participant

1033 points

600 Posts

Re: Re: Beta2: Border shows around TextBox...

 Mark, thanks for the feedback and information!

___________
Best Regards;
..Ben

Silverlight & WPF Insider
Please visit www.MicroIntelligence.Com For our services!

jackbond
jackbond

Contributor

Contributor

2820 points

725 Posts

Re: Beta2: Border shows around TextBox...

Mark Rideout:
This default style ignores the border thickness and border brush.

Will this be fixed in the next release?

BenHayat
BenHayat

Participant

Participant

1033 points

600 Posts

Re: Beta2: Border shows around TextBox...

jackbond:

Will this be fixed in the next release?

 

I don't think Mark's point was, that, this is a bug! 

___________
Best Regards;
..Ben

Silverlight & WPF Insider
Please visit www.MicroIntelligence.Com For our services!

davidpni
davidpni

Member

Member

66 points

82 Posts

Re: Beta2: Border shows around TextBox...

Could you give more information on editing it to eliminate the border?  I also would not like borders around my TextBox elements. 

 

Edit:

 

Nevermind.  To anyone who wants a TextBox with no borders, place this in your App.xaml:

 

        <Style x:Key="TextBoxNoBorder" TargetType="TextBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid x:Name="RootElement">
                            <ScrollViewer x:Name="ContentElement" BorderThickness="0" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


 

jackbond
jackbond

Contributor

Contributor

2820 points

725 Posts

Re: Beta2: Border shows around TextBox...

BenHayat:
I don't think Mark's point was, that, this is a bug!

Well for my money, a default template that ignores explicitely set properties is without question a bug. Does it ignore the background property as well? How about the text alignment? Oh ok, so I have to read the docs to figure out which properties are actually respected? That aint software development, that's voodoo.

BenHayat
BenHayat

Participant

Participant

1033 points

600 Posts

Re: Beta2: Border shows around TextBox...

 Jack, I hear you. I was the one who got hit last night and spent the whole night converting TextBox to TextBlocks for Read-only cases. But I was not going to argue with Mark, since their new design had changed things around. So I called it a "Change" rather than a "Bug" :-)

___________
Best Regards;
..Ben

Silverlight & WPF Insider
Please visit www.MicroIntelligence.Com For our services!

virtuousleo11
virtuous...

Member

Member

2 points

1 Posts

Re: Beta2: Border shows around TextBox...

 hi davidpni, i used your code and it works fine, but the problem is that my textboxes are not editable now (after integrating your code in app.xaml and if i remove your code they becomes editable but borders are there). Could u plz help me with this one?

Anton Sivov
Anton Sivov

Member

Member

2 points

4 Posts

Re: Beta2: Border shows around TextBox...

Mark Rideout:

The new visual style for TextBox uses gradients inside a Grid. This default style ignores the border thickness and border brush.
To remove the border you'll need to replace the tempalte. You can use Expression Blend to modify the template (this is the easiest way).
Here is what the default template looks like: ...

 

I've a problem with textBox control when apply the template. It does not want be focused. Could you help me?

manor
manor

Member

Member

41 points

44 Posts

Re: Beta2: Border shows around TextBox...

I want to get the same effect? How to update the  control template for textbox? Where to find it?

samcov
samcov

Participant

Participant

969 points

379 Posts

Re: Beta2: Border shows around TextBox...

jackbond:

BenHayat:
I don't think Mark's point was, that, this is a bug!

Well for my money, a default template that ignores explicitely set properties is without question a bug. Does it ignore the background property as well? How about the text alignment? Oh ok, so I have to read the docs to figure out which properties are actually respected? That aint software development, that's voodoo.

Of course this is a bug. 

It's almost like somebody had a bright idea, but failed to test it.

I had a mouse over effect that changed the border color, and POOF, it doesn't work anymore.

Sam...

 

"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities