Click here to Skip to main content
15,881,281 members
Articles / Desktop Programming / WPF

A C# WPF .NET 4.0 "DataGrid" with Persistent Controls in Cells

Rate me:
Please Sign up or sign in to vote.
4.29/5 (10 votes)
29 Aug 2011CPOL10 min read 47.5K   2.4K   28  
A DataGrid lookalike that has persistent controls in cells
<UserControl x:Class="PersistDataGrid.Header"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignWidth="144"
             PreviewMouseLeftButtonDown="UserControl_PreviewMouseLeftButtonDown"
             GotMouseCapture="UserControl_GotMouseCapture">
    <UserControl.Resources>
        <Style  x:Key="HeaderStyle" TargetType="{x:Type Border}">
            <Setter Property="Background" Value="{StaticResource DGP_Head_NormalBrush}"/>
            <Setter Property="BorderBrush" Value="{StaticResource DGP_Head_NormalBorderBrush}"/>
            <Style.Triggers>
                <Trigger Property="Border.IsMouseOver" Value="true">
                    <Setter Property = "Background" Value="{StaticResource DGP_Head_HighlightBrush}"/>
                    <Setter Property = "BorderBrush" Value="{StaticResource DGP_Head_HighlightBorderBrush}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style  x:Key="NoArrowStyle" TargetType="{x:Type Path}">
            <Setter Property="Fill" Value="Transparent"/>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Border Name="HeaderBorder" Style="{StaticResource HeaderStyle}" BorderThickness="1,0,0,1">
            <Label Name="Title"/>
        </Border>
        <Path Name="Arrow"/> 
    </Grid>
</UserControl>

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
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions