Home Forums WPF controls Xceed DataGrid for WPF Changing cells background color still leaves white border

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

    I found the following code on the forum to change the background color of cells which works, but there is a white border around each cell. Can I get rid of the white border around the cells so that the color I am setting it to covers the entire cell? I tried setting the Padding to “0,0,0,0” but that did not work.

    <DataTemplate x:Key=”readOnlyColumn”>
    <TextBlock Text=”{Binding}” Background=”Wheat” />
    </DataTemplate>

    <xcdg:DataGridControl Name=”xgdMarkPrice” Grid.Row=”2″>

    <xcdg:DataGridControl.Columns>

    <xcdg:Column FieldName=”Issuer” CellContentTemplate=”{StaticResource readOnlyColumn}” />

    <xcdg:Column FieldName=”Asset” CellContentTemplate=”{StaticResource readOnlyColumn}” />

    <xcdg:Column FieldName=”SecurityID” CellContentTemplate=”{StaticResource readOnlyColumn}” />

    </xcdg:DataGridControl.Columns>

    </xcdg:DataGridControl>

    Thanks,

    Breeze

    Imported from legacy forums. Posted by Steve (had 3963 views)

    Xceed Support
    Member
    Post count: 5658

    The reason for the border is that you are providing a new template for the cell’s content and not the cell itself. That said, providing a new DataCell ControlTemplate rather than a DataTemplate will do what you want.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 206 views)

    User (Old forums)
    Member
    Post count: 23064

    Could you provide a short sample? I’ve tried a bunch of different stuff but can’t seem to get it to work.

    Imported from legacy forums. Posted by Steve (had 303 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried this and nothing happens. Cell looks the same.

    <ControlTemplate x:Key=”readOnlyColumn” TargetType=”{x:Type xcdg:DataCell}”>
    <TextBlock Text=”{Binding}” Background=”Wheat” />
    </ControlTemplate>

    Imported from legacy forums. Posted by Steve (had 346 views)

    Xceed Support
    Member
    Post count: 5658

    If all you want to do is make a column readonly and change the background of its cells, I suggest you do the following:

    <Style TargetType=”{x:Type xcdg:DataCell}”>
    <Style.Triggers>
    <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Self}, Path=FieldName}”
    Value=”ShipCountry”>
    <Setter Property=”Background” Value=”Wheat”/>
    <Setter Property=”ReadOnly” Value=”True”/>
    </DataTrigger>
    </Style.Triggers>
    </Style>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 219 views)

    User (Old forums)
    Member
    Post count: 23064

    That did the trick! I got close but did not have the Binding code. Thanks for the code sample. Replies with code samples rock!

    Breeze

    Imported from legacy forums. Posted by Steve (had 5130 views)

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