Home Forums WPF controls Xceed DataGrid for WPF Subclass DataGridControl in XAML

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24766 |

    I’m trying to subclass the DataGridControl in XAML. The subclass works, but none of the XAML properties are applying when I use the subclass. It’s all defaults. The only strange thing was I had to comment out InitializeComponent(), but maybe DataGridControl isn’t a UIElement.

    Here’s how I’m using the subclass in my window:

    <local:PacketDataGridControl x:Name=”PacketGrid”
    ItemsSource=”{Binding Source={StaticResource searchDataView}, Path=View}”
    />

    Here is the XAML file:

    <xcdg:DataGridControl x:Class=”NameSpace.PacketDataGridControl”
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;
    xmlns:compModel=”clr-namespace:System.ComponentModel;assembly=WindowsBase”
    CellEditorDisplayConditions=”MouseOverCell”
    EditTriggers=”BeginEditCommand,ActivationGesture”
    ItemScrollingBehavior=”Immediate” AutoCreateColumns=”True”
    ItemsSource=”{Binding Source={StaticResource searchDataView}, Path=View}”
    HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch” FontSize=”12″
    Background=”gray”>

    <!– Sets up vertical scrolling –>
    <xcdg:DataGridControl.Resources>
    <Style TargetType=”{x:Type xcdg:CardViewScrollViewer}”>
    <Setter Property=”HorizontalScrollBarVisibility” Value=”Disabled” />
    </Style>
    </xcdg:DataGridControl.Resources>

    <!–We want to see all the cells, even when they’re empty–>
    <xcdg:DataGridControl.View >
    <xcdg:CompactCardView Theme=”{DynamicResource defaultTheme}” HideEmptyCells=”False”>
    <xcdg:CompactCardView.FixedHeaders>
    <!– Don’t show the header used for grouping –>
    <xcdg:ClearHeadersFooters/>
    </xcdg:CompactCardView.FixedHeaders>
    </xcdg:CompactCardView>
    </xcdg:DataGridControl.View>
    <xcdg:DataGridControl.ItemsPanel>
    <ItemsPanelTemplate>
    <xcdg:VirtualizingStackPanel Orientation=”Vertical” />
    </ItemsPanelTemplate>
    </xcdg:DataGridControl.ItemsPanel>

    <!– Map column names to user friendly ones–>
    <xcdg:DataGridControl.Columns >
    <xcdg:Column FieldName=”HeaderOrg” DisplayMemberBinding=”{Binding Path=Org,Mode=TwoWay}”/>
    <xcdg:Column FieldName=”HeaderCity” DisplayMemberBinding=”{Binding Path=City,Mode=TwoWay}”/>
    <xcdg:Column FieldName=”HeaderState” DisplayMemberBinding=”{Binding Path=State,Mode=TwoWay}”/>
    <xcdg:Column FieldName=”Status” CellEditor=”{StaticResource statusEditor}” />
    <xcdg:Column FieldName=”Requested” Title=”Requested” />
    <xcdg:Column FieldName=”Leadsource” Title=”Lead” />
    <xcdg:Column FieldName=”Sendpk” Title=”Send Packet” />
    <xcdg:Column FieldName=”Posters” Title=”Send Posters” />
    <xcdg:Column FieldName=”Salesheets” Title=”Sales Sheets” />
    <xcdg:Column FieldName=”Shipmethod” Title=”Ship Method” />
    <xcdg:Column FieldName=”Shipped” Title=”Shipped” />
    <xcdg:Column FieldName=”Addverified” Title=”Verified” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    Imported from legacy forums. Posted by Brian (had 519 views)

    Xceed Support
    Member
    Post count: 5658

    Normally, when I create a class that derives from DataGridControl, I simply replace all references to DataGridControl with my new class (e.g., CustomGrid ). So rather than having

    <xcdg:DataGridControl x:Class=”NameSpace.PacketDataGridControl” …

    Simply use <local:CustomGrid…

    so xcdg:DataGridControl.Columns would become local:CustomGrid.Columns

    and so on.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 371 views)

    User (Old forums)
    Member
    Post count: 23064

    Jenny,

    I’m not sure I follow. Are you saying I need to subclass each of these controls individually?

    xcdg:DataGridControl.View
    xcdg:CompactCardView.FixedHeaders
    xcdg:ClearHeadersFooters
    xcdg:DataGridControl.ItemsPanel
    xcdg:VirtualizingStackPanel
    xcdg:DataGridControl.Columns
    xcdg:Column

    Brian

    Imported from legacy forums. Posted by Brian (had 3493 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.