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.
I am binding Xamdatagrid to DataTable but BorderColor is not column in DataTable. In my case, DataTable columns are Name, Description,SRLoLimit,Status,Value
c1 = new ColumnInfo("Name", DisplayType.TextBlock, new CellInfo(Brushes.Purple),false);
c2 = new ColumnInfo("Description", DisplayType.TextBlock);
c3 = new ColumnInfo("SRLoLimit", DisplayType.Button);
c4 = new ColumnInfo("Status", DisplayType.ComboBox, MyProperty);
c5 = new ColumnInfo("Value", DisplayType.TextBox);
And 2nd Parameter for ColumnInfo is UI Type. and 3rd parameter is BorderColor
And I am updating DataRows information from RowInfo class as below
RowInfo row2 = new RowInfo();
row2.rowData.Add("CV002");
row2.rowData.Add("Sample Description CV002");
row2.rowData.Add("0");
row2.rowData.Add("InActive");
row2.rowData.Add("200");
rows.Add(row2);
foreach (RowInfo rowItem in Rows) {
dr = dt.NewRow();
for (int i = 0; i < Columns.Count; i++)
{ dr[Columns[i].Name] = rowItem.rowData[i];
}
dt.Rows.Add(dr);
Consider, I want to apply the BorderColor property to BorderBrush and the BorderColor value is getting from ColumnInfo.CellInfo and it should be applicable only to value "CV002".
So Could you please let me how can I achieve the above mentioned in Style of CellValuePresenter.
Thank you,
Hello,
Thank you for your reply. I have been looking into your last post and if you want to set ‘BorderBrush’ property when applying the ‘CellValuePresenter’ style, you can try to check the coming value from ColumnInfo.CellInfo by some ‘if’ state.
Let me know, if I cannot understand your scenario completely.
Thanks for your email..
I have been looking into your last post and if you want to set ‘BorderBrush’ property when applying the ‘CellValuePresenter’ style, you can try to check the coming value from ColumnInfo.CellInfo by some ‘if’ state.
Yes. The BorderBrush property need to be set from ColumnInfo.CellInfo class(BorderColor) property.and it need to apply to cell when CellValuePresenterstyle is applied.
Could you please help me,how can achieve the above scenario.
Have you got a chance to look into the issue?
Could you please help me with sample
Thanks in advance,
Regards,
Hi Chandra,
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.
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://es.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 am just checking if you require any further assistance on the matter.
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..