Home Forums WPF controls Xceed DataGrid for WPF Column of vertical stackpanel of 2 labels

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

    I’m trying to define the 3rd column of my datagrid to be a vertical stackpanel of 2 readonly labels that I set in the XAML code. When I run the application, I get the message;

    “Cannot add content of type ‘Xceed.Wpf.DataGrid.Column’ to an object of type ‘Xceed.Wpf.DataGrid.ColumnCollection'”

    This is how I’ve defined the column;

    <!–Styles–>
    <Style x:Key=”ComboBoxStackPanel”>
    <Setter Property=”StackPanel.Orientation” Value=”Vertical”/>
    <Setter Property=”FrameworkElement.VerticalAlignment” Value=”Center”/>
    </Style>

    <!– DataTemplate–>
    <DataTemplate x:Key=”labelsCellTemplate”>
    <StackPanel Orientation=”Vertical” Style=”{StaticResource ComboBoxStackPanel}” >
    <TextBlock Text=”Label1″ />
    <TextBlock Text=”Label2″ />
    </StackPanel>
    </DataTemplate>

    <!– 2 labels –>
    <xcdg:Column Title=”Type”
    Width=”70″
    CellContentTemplate=”{StaticResource labelsCellTemplate}”
    ReadOnly=”True”
    />

    How can I get these labels to show up? They aren’t data tied with the data source I’m binding, but they are the actual names of the data member variables. So maybe I could bind the names?

    Thanks,
    Shelley

    Imported from legacy forums. Posted by Shelley (had 2376 views)

    User (Old forums)
    Member
    Post count: 23064

    I havn’t tried it, but my guess is that if you set the FieldName property of the Column instance to some (perhaps existing) field name value, then it should work.

    The error message of not being able to add a Column to a ColumnCollection is a bit misleading, though.

    In my opinion, this design restriction of “one colunn == one property in the underlying transfer object” is a bit too strict. It would be nice to have better support for columns referring to zero or multiple properties (even if there were limitations in sorting, grouping and filtering).

    Kuno

    Imported from legacy forums. Posted by Kuno (had 386 views)

    User (Old forums)
    Member
    Post count: 23064

    This worked…

    <DataTemplate x:Key=”TypeCellTemplate”>
    <StackPanel Orientation=”Vertical” Style=”{StaticResource ComboBoxStackPanel}” >
    <Label Content=”Label1″/>
    <Label Content=”Label2″/>
    </StackPanel>
    </DataTemplate>

    <xcdg:CellEditor x:Key=”TypeLabels”>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <StackPanel Tag=”Amount” Orientation=”Vertical”>
    <Label Content=”Label1″/>
    <Label Content=”Label2″/>
    </StackPanel>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    <xcdg:CellEditor.ActivationGestures>
    <xcdg:KeyActivationGesture Key=”Up”/>
    <xcdg:KeyActivationGesture Key=”Down”/>
    </xcdg:CellEditor.ActivationGestures>
    </xcdg:CellEditor>

    and later in the grid…

    <xcdg:Column
    FieldName =”Label1″
    Title=”Type”
    Width=”70″
    CellEditor=”{StaticResource TypeLabels}”
    CellContentTemplate=”{StaticResource TypeCellTemplate}”
    />

    Imported from legacy forums. Posted by Shelley (had 3565 views)

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