Click here to Skip to main content
15,892,005 members
Articles / Desktop Programming / WPF

CodeBox

Rate me:
Please Sign up or sign in to vote.
4.91/5 (34 votes)
10 Mar 2009CPOL7 min read 98.9K   2.3K   95  
A fast WPF textbox control with support for text coloring, highlighting, underlines, and strikethroughs.
<Window x:Class="CodeBoxDemo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:CodeBoxControl;assembly=CodeBoxControl"
      xmlns:l="clr-namespace:System.Linq;assembly=System.Core"
    Title="CodeBox Demo" Height="340" Width="528">
    <DockPanel>
        <ToolBarPanel DockPanel.Dock="Top" >
            <ToolBar>
                <Button Name="btSQL" Click="btSQL_Click">SQL</Button>
                <Separator/>
                <Button Name="btStyles" Click="btStyles_Click">Styles</Button>
                <Separator/>
                <Button Name="btClear" Click="btClear_Click">Clear</Button>
                <Separator/>
                <Label >Font</Label>
                <ComboBox Name="cmbFont"  ItemsSource="{Binding Source={x:Static Fonts.SystemFontFamilies}}"
                      SelectedValue="{Binding ElementName=txtTest, Path=FontFamily}"></ComboBox>
                <Separator/>
                <Label >Size</Label>
                <ComboBox Name="cmbSize"  SelectedValue="{Binding ElementName=txtTest, Path=FontSize}"
                           ></ComboBox>
                <Separator/>
            </ToolBar>
        </ToolBarPanel>
        <StackPanel   DockPanel.Dock="Top" ></StackPanel>
        <StatusBar  DockPanel.Dock="Bottom" >
            <StatusBarItem>
                <TextBlock Name="TimeReport"></TextBlock>
            </StatusBarItem>
        </StatusBar>
        <Grid Background="White"   >
            <c:CodeBox Background="#0025223E" TextWrapping="Wrap" Margin="4,4,4,4" Foreground="#0025223E" Name="txtTest" FontSize="12" VerticalScrollBarVisibility="Auto" FontFamily="Courier New" BaseForeground="Black" AutoWordSelection="False"></c:CodeBox>

        </Grid>

    </DockPanel>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Written software for what seems like forever. I'm currenly infatuated with WPF. Hopefully my affections are returned.

Comments and Discussions