views:

34

answers:

2

Hi,

Very simple question ...

Can I use the WPF datagrid control in the same way I use a regular grid ?

How can I do the following but using a WPF datagrid instead of using the standard Grid ?

<Grid Width="542" Margin="0,12,0,0" HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition  Width="182"  />
            <ColumnDefinition  Width="360" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Label Grid.Row="0" Grid.Column="0" >
                Configuration Software:
        </Label>
        <TextBlock Grid.Row="0" Grid.Column="1"  Text="{Binding Path=Software.Name}">  
        </TextBlock>
    </Grid>
A: 

No, the WPF Datagrid is a control used to show data that is bound to it.

The WPF Grid control is a layout container.

masenkablast
A: 

I'm not sure what you mean by "the same way", but if you expect to represent the data in XAML like you did with the example and manually assign the value for each cells (like the old days, believe me I too have had times when I wish this is possible), you can't.

The data should be represented in a class instead, a collection of this class is then bound to the data grid. If you need to customise display for every row/cell you would have to work with the underlying template (which sometimes could be lot of work).

Jaya Wijaya