tags:

views:

729

answers:

1

Hi, I am Having requirement on WPF Datagrid row,Whenever user selects a DatagridRow,corresponding datagrid Cells borders should have thickness of 1 or 2 .

or Provide margin for textboxes/Textblocks within in DatagridCell.

With regards, Mahens

A: 

I'm not sure if this is exactly what you're looking for, but here's an example of modifying the default listboxitem style for a gridview (NOTE the top level Grid is the top-level element in a xaml file):

    <Grid>
        <Grid.Resources>
            <Style x:Key="itemstyle" TargetType="{x:Type ListBoxItem}">
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="BorderThickness" Value="3"/>
                        <Setter Property="BorderBrush" Value="Black"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
        <ListView Name="grid" ItemContainerStyle="{StaticResource itemstyle}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
                    <GridViewColumn Header="Age" DisplayMemberBinding="{Binding Path=Age}"/>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>

I just created a generic Person type with a Name string property and an int Age property. I added a few of these to a list and set the ItemsSource of grid to the List.

Mark Synowiec
Hi Mark,Thanks for Help.But im looking for wpf datagrid row,Upon selecting wpf datagrid row,corresponding cells in that row should get bordered with different colour or different thickness
I see. I think you'd have to use something like a datatemplateselector for the celltemplateselector of the individual cells you want to modify. i was playing around with it and couldn't get the selector to fire off of a selection change, so you might need to do something about that. ill try to look into it more when i get some time.
Mark Synowiec