Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create Textbox with Dashed Border or Double Line Border [closed]

Tags:

c#

wpf

xaml

How to create the following two textboxes (NOT rectangles) in XAML or C# code

Textboxes with border

like image 651
dongx Avatar asked Nov 27 '12 23:11

dongx


1 Answers

You could use rectange to create the "Dash" style

<Window x:Class="WpfApplication5.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock Width="200" Height="40" Name="Textblock1" Text="Hello World!" TextAlignment="Center" FontSize="20"/>
        <Rectangle Width="{Binding ElementName=Textblock1, Path=ActualWidth}" Height="{Binding ElementName=Textblock1, Path=ActualHeight}" StrokeDashArray="0.0 6.0 0.0" Stroke="Black" StrokeThickness="2"  />
    </Grid>
</Window>

enter image description here

And for double line you could possibly create 2 borders

<Window x:Class="WpfApplication5.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Border BorderBrush="Black" Width="200" Height="40" BorderThickness="1">
            <Border BorderBrush="Black" Margin="2" BorderThickness="1">
                <TextBlock  Name="Textblock1" Text="Hello World!" TextAlignment="Center" FontSize="20"/>
            </Border>
        </Border>
    </Grid>
</Window>

enter image description here

like image 88
sa_ddam213 Avatar answered Nov 14 '22 23:11

sa_ddam213