Appliquer un FontFamily sur une colonne
Bonjour,
je cherche actuellement à appliquer un Fontfamily (défini dans un converter) à une datagridColumn.
J'ai donc le converter suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| FontFamily returnValue = new FontFamily("Time New Roman");
if (value == null || value.ToString() == "normal")
{
returnValue = new FontFamily("Time New Roman");
}
else if (value == null || value.ToString() == "gras")
{
returnValue = new FontFamily("Time New Roman Bold");
}
else if (value == null || value.ToString() == "gris")
{
returnValue = new FontFamily("Time New Roman Gray");
}
return returnValue; |
Et j'essaye de l'appliquer comme suit, sans succès :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
<sdk:DataGridTextColumn Header="Libellé"
Width="60"
Binding="{Binding Lib, Mode=TwoWay}"
ToolTipService.ToolTip="{Binding LibQualite}">
<sdk:DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="FontFamily" Value="{Binding rowStyle, Converter={StaticResource RowStyleConverter}}" />
</Style>
</sdk:DataGridTextColumn.ElementStyle>
</sdk:DataGridTextColumn> |
J'ai aussi essaye d'appliquer cela à ma datagrid, pour que cela change le style toute la ligne, mais sans succès :
Code:
1 2 3 4 5 6 7 8 9 10
|
<sdk:DataGrid Grid.Row="0"
Grid.Column="0"
Name="dgListe"
VerticalAlignment="Top"
HorizontalAlignment="Left"
AutoGenerateColumns="False"
AlternatingRowBackground="Orange"
FontFamily="{Binding rowStyle, Converter={StaticResource RowStyleConverter}}"
IsReadOnly="True"> |
Comment pourrais je faire, pour changer la police de texte de chaque ligne, en fonction de la valeur obtenue grace à mon converter? Que je doive le faire en xaml, ou bien dans le code Behind(en bouclant sur les éléments de la datagrid).
Merci.