Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug Beta2: Border shows around TextBox...
11 replies. Latest Post by samcov on July 3, 2008.
(0)
BenHayat
Participant
1033 points
600 Posts
06-08-2008 3:57 PM |
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?
Mark Rid...
Contributor
2357 points
273 Posts
06-08-2008 9:25 PM |
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,-markSilverlight Program Manager
06-09-2008 7:20 AM |
Mark, thanks for the feedback and information!
jackbond
2820 points
725 Posts
06-09-2008 1:56 PM |
Mark Rideout:This default style ignores the border thickness and border brush.
Will this be fixed in the next release?
06-09-2008 2:16 PM |
jackbond:Will this be fixed in the next release?
I don't think Mark's point was, that, this is a bug!
davidpni
Member
66 points
82 Posts
06-09-2008 2:57 PM |
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>
06-09-2008 4:18 PM |
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.
06-09-2008 4:26 PM |
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" :-)
virtuous...
2 points
1 Posts
06-10-2008 6:41 AM |
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
4 Posts
06-11-2008 8:48 AM |
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: ...
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
41 points
44 Posts
06-11-2008 3:54 PM |
I want to get the same effect? How to update the control template for textbox? Where to find it?
samcov
969 points
379 Posts
07-03-2008 4:31 PM |
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...