Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
290
Change text alignement in a cell
posted

Hi,

I would like to change the text alignement in a cell. My first idea is to set the Template for CellValuePresenter and define my own TextBlock. It works but I loose much of the functionality of the XamDataGrid. Editing is no more possible (without coding), selection, ...

So I took a look in your samples an tried this:

 

 

 

 

 

 

 

 

 

 

<Style TargetType="{x:Type igDP:CellValuePresenter}">

 

 

 

 

<Setter Property="Foreground" Value="{DynamicResource GeneralForeground}" />

 

 

 

 

<Setter Property="Background" Value="{DynamicResource GeneralBackground}" />

 

 

 

 

<Setter Property="HorizontalAlignment" Value="Center" />

 

 

 

 

</Style>

The Text is centered but the Background color no more fills the whole cell. Then I tried this:

 

 

 

<Style TargetType="{x:Type igDP:CellValuePresenter}">

 

 

 

<Setter Property="Foreground" Value="{DynamicResource GeneralForeground}" />

 

 

 

<Setter Property="Background" Value="{DynamicResource GeneralBackground}" />

 

 

 

<Setter Property="HorizontalAlignment" Value="Stretch" />

 

 

 

<Setter Property="TextBlock.TextAlignment" Value="Center" />

 

 

 

</Style>

Now the background color fills the whole cell but the text is only centered when editing. I think I'm missing something...

Could someone help me?

Thanks,

Daniel

PS: In the preview the code is not easily readable... How shoud l insert code snippets correctly in the forum?