Home Forums WPF controls Xceed DataGrid for WPF new ControlTemplate for InsertionRow?

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

    Hi,

    Is it possible to create a new ControlTemplate for an InsertionRow object?
    I have created one for the DataRow object but when I create a copy of that template and change it’s TargetType to InsertionRow, the template seems to be ignored…

    Thanks for your reply.

    Cheers
    Arjan

    Imported from legacy forums. Posted by Arjan (had 3801 views)

    Xceed Support
    Member
    Post count: 5658

    Can you provide the code used to setup the control template?

    Imported from legacy forums. Posted by Marcus [Xceed] (had 319 views)

    User (Old forums)
    Member
    Post count: 23064

    This is the code:

    <Style x:Key=”insertionrow_style” TargetType=”{x:Type xcdg:InsertionRow}”>
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate TargetType=”{x:Type xcdg:InsertionRow}”>
    <Grid x:Name=”rootGrid”>
    <Grid.RowDefinitions>
    <RowDefinition Height=”Auto”/>
    <RowDefinition Height=”*”/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
    <!– GroupLevelIndicatorPane –>
    <ColumnDefinition Width=”Auto” />

    <!– CellsHost panel –>
    <ColumnDefinition Width=”175″ />
    <ColumnDefinition Width=”175″ />
    <ColumnDefinition Width=”175″ />
    <ColumnDefinition Width=”*” />
    </Grid.ColumnDefinitions>

    <!– The border responsible for the visual outline of the row (gridlines and background)
    spans the GroupLevelIndicatorPane and CellsHost Panel. Those 2 elements are not children of
    the Border because we don’t want the border to be displayed in the GroupLevelIndicatorPane. –>
    <Border x:Name=”rootBorder”
    Grid.Column=”0″
    Grid.ColumnSpan=”5″
    Grid.RowSpan=”2″
    BorderThickness=”1″
    BorderBrush=”AliceBlue”
    />

    <!– GroupLevelIndicatorPane is a placeholder for individual GroupLevelIndicator elements that are added
    whenever this Row is part of a group. –>
    <xcdg:GroupLevelIndicatorPane x:Name=”groupLevelIndicatorPane”
    Grid.Column=”0″ />

    <!– The PART_CellsHost part designates the Panel to which this Row’s Cells should be added.–>
    <StackPanel x:Name=”PART_CellsHost”
    Grid.Column=”1″
    Grid.ColumnSpan=”4″
    Grid.Row=”0″
    Orientation=”Horizontal” />
    <StackPanel Grid.Column=”1″
    Grid.Row=”1″
    Orientation=”Horizontal”>
    <xcdg:DataCell FieldName=”StartShip”/>
    </StackPanel>
    <StackPanel Grid.Column=”2″
    Grid.Row=”1″
    Orientation=”Horizontal”>
    <xcdg:DataCell FieldName=”StopShip”/>
    </StackPanel>
    <StackPanel Grid.Column=”3″
    Grid.Row=”1″
    Orientation=”Horizontal”>
    <xcdg:DataCell FieldName=”Style.Description”/>
    </StackPanel>
    <StackPanel Grid.Column=”4″
    Grid.Row=”1″
    Orientation=”Horizontal”>
    <xcdg:DataCell FieldName=”Style.FamilyName”/>
    </StackPanel>

    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    Imported from legacy forums. Posted by Arjan (had 342 views)

    Xceed Support
    Member
    Post count: 5658

    How are you affecting this style to the InsertionRow? (the style is not implicit)

    Also, I advise against the addition of “DataCells” explicitelly in the Template of an InsertionRow… You should be using InsertionCells.

    At the same time, there is a great potential of simplification to your template as each of the cell is enclosed within a StackPanel that have no other children.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 195 views)

    User (Old forums)
    Member
    Post count: 23064

    “How are you affecting this style to the InsertionRow? (the style is not implicit) “

    a-ha…that would explain why it is ignored. I figured it would work the same as DataRow.
    What is the suggested way of doing this?

    “Also, I advise against the addition of “DataCells” explicitelly in the Template of an InsertionRow… You should be using InsertionCells. “

    Thanks for the tip. I did not notice the existence of that class yet.
    I think an example of providing a new template for InsertionRow is most welcome in the next release 🙂

    Imported from legacy forums. Posted by Arjan (had 436 views)

    Xceed Support
    Member
    Post count: 5658

    In fact, there is a small twist in the way you can assign a style to the DataRow class…

    As for any other class, you can provide the style implicitly… But you can do it through the ItemContainerStyle property of the DataGridControl as well… This is mainly done so that it’s easy to specify different DataRow styles for different DataGridControl…

    On the other hand, you could be specifying the InsertionRow style “manually”…

    <code>
    <xcdg:TableView>
    <xcdg:TableView.Headers>
    <DataTemplate>
    <xcdg:InsertionRow Style=”{StaticResource myResourceKey}”/>
    </DataTemplate>
    </xcdg:TableView.Headers>
    <xcdg:TableView>
    </code>

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4973 views)

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