Home Forums WPF controls Xceed DataGrid for WPF Custom header with out losing resize ability.

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

    hello
    I am new to Xceed so forgive me if it’s a stupid question.
    I need to change the appearance of the grid header to a textblock and a combobox.
    I did that but I lost the ability to resize the columns.
    My xaml:

    <my1:DataGridControl Margin=”1,0,0,0″ Grid.Column=”1″ Name=”InventoryGrid” xmlns:my1=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid” ReadOnly=”True” ItemScrollingBehavior=”Deferred” EditTriggers=”BeginEditCommand, ClickOnCurrentCell, CellIsCurrent, ActivationGesture” NavigationBehavior=”RowOrCell”>
    <my1:DataGridControl.Columns>
    <my1:Column FieldName=”No” IsMainColumn=”True” ReadOnly=”True” Title=”No” MinWidth=”1″ Width=”50″>
    </my1:Column>
    </my1:DataGridControl.Columns>
    <my1:DataGridControl.Resources>
    <Style TargetType=”{x:Type my1:ColumnManagerCell}”>
    <Setter Property=”my1:ColumnManagerCell.Template”>
    <Setter.Value>
    <ControlTemplate>
    <Grid Background=”Blue”>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width=”20″ />
    <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <ComboBox Grid.Column=”1″ Height=”20″ Name=”comboBox1″ Margin=”1″ MinWidth=”70″ />
    <TextBlock Grid.Column=”0″ Text=”{TemplateBinding my1:ColumnManagerCell.Content}”
    TextAlignment=”Center”
    VerticalAlignment=”Center” />
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </my1:DataGridControl.Resources>
    <my1:DataGridControl.View>
    <my2:TableView UseDefaultHeadersFooters=”False” ShowScrollTip=”False” ShowFixedColumnSplitter=”False” ShowRowSelectorPane=”False”>
    <my2:TableView.FixedHeaders>
    <DataTemplate>
    <my1:ColumnManagerRow AllowAutoFilter=”False” AllowColumnReorder=”False” AllowSort=”False” >
    <my1:ColumnManagerCell />
    </my1:ColumnManagerRow>
    </DataTemplate>
    </my2:TableView.FixedHeaders>
    </my2:TableView>
    </my1:DataGridControl.View>
    </my1:DataGridControl>

    What should I do to be able to resize the columns?

    Imported from legacy forums. Posted by david (had 2350 views)

    Xceed Support
    Member
    Post count: 5658

    With the WPF framework, it is important to make the difference between ControlTemplates and DataTemplates.

    In this case, you are affecting a new ControlTemplate to the ColumnManagerRow. ControlTemplate defines the visual look of a control, but also has to respect certain contracts for the feature of the control to remain intact. These contracts are named Template parts.

    You can get an overview of the different Template Parts of the DataGrid for WPF Objet Model in this documentation topic:

    <a href=”http://doc.xceedsoft.com/products/XceedWpfDataGrid/Templates.html”>http://doc.xceedsoft.com/products/XceedWpfDataGrid/Templates.html</a&gt;

    On the other hand, if what you need is to change how the Content of the ColumnMangerCell is displayed, you are probably better off changing the DataTemplate which is in charge of showing the Header’s content.

    The DataTemplate used to display the ColumnManagerCell’s Content is the Column.TitleTemplate property.

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

    User (Old forums)
    Member
    Post count: 23064

    Following up on David’s question about adding a combobox in the column header.  Let’s say he has created the DataTemplate (wiith a combobox in it) and assigned it to the TitleTemplate property of xcdg:Column, how should the binding be setup on the combobox ItemsSource so that it can dynamically display items?

     

    Many thanks

    Imported from legacy forums. Posted by Erik (had 526 views)

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