Hi,
As per my requirement , I need to apply specific style for Cell.
Once you applied style, Cell will have Value, Border Color and image depends on the collection set it in binding.
To achieve above requirement..which Targettype need to be used to apply Style?
Thanks,
Chandra
Hello Chandra,
Thank you for post. If you are working with XamGrid, you need to create a style with target element “CellControl” :
http://help.infragistics.com/Help/NetAdvantage/WPF/2012.2/CLR4.0/html/Designers_Guide_Styling_Points_for_xamGrid.html
If working with the XamDataGrid, you need style for “CellValuePresenter” :
http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/InfragisticsWPF4.DataPresenter.v12.1~Infragistics.Windows.DataPresenter.CellValuePresenter.html
Let me know, if you need any further assistance on this matter
Hi Yanko,
I am using XamDataGrid Control. So I created style for CellvaluePresenter .
>>
<Style x:Key="InCellStyle" TargetType="{x:Type igDP:CellValuePresenter}" > <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <Border CornerRadius="2" Name="MainBorder" BorderThickness="2" BorderBrush="{Binding BorderColor,FallbackValue=Red}"> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="TextBlock" Text="{Binding Value, FallbackValue=99,RelativeSource={RelativeSource Mode=TemplatedParent}}" /> <Image x:Name="Image1" Source="{Binding}"/> <!--<Image Width="Auto" Source="pack://application:,,,/WpfCustomControlLibrary7;component/Images/WarningImg.png" HorizontalAlignment="Right" x:Name="Image1" />--> </StackPanel> </Border> <!--</Border>--> <ControlTemplate.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:CustomControl1}},Path=EnableWarningFlag}" Value="True"> <Setter Property="Source" TargetName="Image1" Value="pack://application:,,,/WpfCustomControlLibrary7;component/Images/WarningImg.png"></Setter> <Setter Property="BorderBrush" TargetName="MainBorder" Value="Blue"></Setter> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
<<
I want to apply CellvaluePresenter Style for specific cell.
How Can I achieve this?
If I apply above style, I need to get BorderColor ,Value and image in the Cell depends on specific properties
Could you please help me in this.
Hi Chandra,
Thank you for your feedback. The easiest way to apply ‘CellValuePresenter’ style for specific cell of the XamDataGrid is by code. For example, in the ‘Loaded’ event :
private void xamDataGrid1_Loaded(object sender, RoutedEventArgs e)
{
Style cellChangedStyle = this.LayoutRoot.Resources["cellValuePres"] as Style;
CellValuePresenter.FromCell((this.xamDataGrid1.Records[0] as DataRecord).Cells[0]).Style = cellChangedStyle;
}
Also you can set the desired properties in the style through code.
Let me know, if you need any further assistance on this matter.
Could you please provide me some sample example...so that i can use it as reference.
Thank you,
I am just checking if you require any further assistance on the matter.
Thanks for your help..
As per your solution, we are writing converter, where we can check exact cell values with some conditions.
But in my case, everything has to do dynamically...
Anyway..thanks for your help..
I have posted one more post..
http://ko.infragistics.com/community/forums/t/78661.aspx
If the above mentioned problem rectifies..my problem will be resolved..
Could you please look into above issue?
I have been looking into your sample application and after thorough research I believe that setting the border brush through accessing the properties of your ColumnInfo and CellInfo is not an appropriate approach because they cannot be accessed by the underlying data of the records in the XamDataGrid. The best approach that I can suggest is by using the border converter :
<local:BorderConverter x:Key="testconv" />
…
BorderBrush="{Binding Converter={StaticResource testconv}}"
public class BorderConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
if ((value as DataRecord).Cells[0].Value.ToString() == "CV002" && (value as DataRecord).Cells[0].Record.Index ==1)
return Brushes.Orange;
else if ((value as DataRecord).Cells[0].Value.ToString() == "CV002" && (value as DataRecord).Cells[0].Record.Index == 2)
return Brushes.Pink;
else
return value;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();
This way you can check the value in the desired cell and its index in the XamDataGrid.
I am attaching my solution, which i am currently working on it.
Thanks in advance..
I am waiting for your response.As i need to implement this as high priority task to me..
Regards,
Would you please attach a sample application following your scenario with the ‘ColumnInfo’ class in order to provide you with more accurate assistance ?
Looking forward to hearing from you.