Hello,
I'm tryng to set background color of row on my Xamgrid.
I make something like this :
<UserControl.Resources> <Style TargetType="{x:Type ig:CellControl}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Cell.Row.CommandeFournisseur.Numero}" Value="IC/140029"> <Setter Property="Background" Value="Red"/> </DataTrigger> </Style.Triggers> </Style> </UserControl.Resources>
But when the value is IC/140029 nothing append...
My xamgrid is like this :
<ig:XamGrid x:Name="dataGrid" AutoGenerateColumns="False" ColumnWidth="auto" FontSize="10" FontFamily="Calibri" Foreground="Black" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" RowHover="Row" RowHeight="20" Margin="5" ItemsSource="{Binding ListeAfterFiltre}">
ListeAfterFiltre is type of ObservableCollection<CommandeFournisseur>
thanks
Hello EASii IC,
Thank you for your post!
I have been looking into it and have created a small sample application for you. In it I have a simple XamGrid bind to a collection. In the collection I have a property UniqueID of type string, which has value - IC/140029.
I have used the style you have provided for the CellControl. Then I have changed the binding for the DataTrigger to
Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataContext.UniqueID}".
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
It's ok with the color but i have a problem with column's height.
The column modif and pdf have a height problem.
My buttons are cut.
My table options are :
<ig:XamGrid x:Name="dataGrid" AutoGenerateColumns="False" ColumnWidth="auto" FontSize="10" FontFamily="Calibri" Foreground="Black" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" RowHover="Row" RowHeight="20" Margin="5" ItemsSource="{Binding ListeAfterFiltre}" >
My buttons are set like this :
<ig:UnboundColumn Key="Modif" HeaderText="Modif" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="50"><ig:UnboundColumn.ItemTemplate><DataTemplate><Button Style="{StaticResource EditButtonStyle}"Height="18" Command="{Binding DataContext.AfficherDetailCommand,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding RowData}"></Button></DataTemplate></ig:UnboundColumn.ItemTemplate></ig:UnboundColumn>
<ig:UnboundColumn Key="PDFFR" HeaderText="PDF FR" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsGroupable="False" IsFilterable="False" IsResizable="False"><ig:UnboundColumn.ItemTemplate><DataTemplate><Button Style="{StaticResource FlatIconeButton}" BorderBrush="White" Background="White" Name="FR"Command="{Binding DataContext.AfficherPDFCommandFR,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ig:XamGrid}}}" CommandParameter="{Binding RowData}"Height="20" Width="20"ToolTip="Afficher le PDF"><ContentControl Style="{StaticResource ERP_PDF_ContentControlStyle}" BorderBrush="Black"/></Button></DataTemplate></ig:UnboundColumn.ItemTemplate></ig:UnboundColumn>
Look at picture
I have been looking into your question.
From the code snippet, that you have provided I was able to see, that you are setting RowHeight property of XamGrid to 20. This way the entire row height would be 20. Around the content of the cells, there are margins and paddings, that can cause the content in the cells to be cut.
What I can suggest is to remove the RowHeight property. This way the height of the rows would be measured according to the content in the cells.
Please do not hesitate to let me know if you have any further questions on this matter.
The RowHeight 20 is good.
The problem appear when i add this :
<UserControl.Resources><Style TargetType="{x:Type ig:CellControl}"><Setter Property="Padding" Value="5 1"/><Style.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataContext.TestAffaireNull}"Value="true"><Setter Property="Background" Value="Red"/></DataTrigger></Style.Triggers></Style></UserControl.Resources>
Margin or padding appear on each row without real reason
EDIT :
To resolve my probleme i have to add : <Setter Property="Padding" Value="5 1"/>
Pciture, i put the 2 case ; 2 lines with and 2 without
Now i have another problem, i have logs with some error like this :
System.Windows.Data Error: 40 : BindingExpression path error: 'TestAffaireNull' property not found on 'object' ''UnboundColumnDataContext' (HashCode=45898110)'. BindingExpression:Path=DataContext.TestAffaireNull; DataItem='CellControl' (Name=''); target element is 'CellControl' (Name=''); target property is 'NoTarget' (type 'Object')
How can i remove this error ?
Thank you for the feedback. Please do not hesitate to let me know if you have any further questions.
I have been looking into your latest post.
Would you please modify the sample application I have provided with the functionality you are using, so it reproduces the issue. This way I would be able to further investigate this issue for you.
Thank you for the cooperation. Looking forward to hearing from you.