Hi all.
I'm working with a conditional format trying to change the cell's style to make it look like a link (blue, underline, cursor hand) based on a condition.
The only thing that works is ForegroundProperty = blue
this is a snippet of my code:
public class MyConditionalFormatRuleProxy : ConditionalFormattingRuleBaseProxy
{
private Style LinkText { get; set; }
public MyConditionalFormatRuleProxy()
Style oLinkStyle = new Style(typeof(ConditionalFormattingCellControl));
oLinkStyle.Setters.Add(new Setter() { Property = ConditionalFormattingCellControl.ForegroundProperty, Value = new SolidColorBrush(Colors.Blue) });
oLinkStyle.Setters.Add(new Setter() { Property = ConditionalFormattingCellControl.CursorProperty, Value = Cursors.Hand });
//Add text decoration to underline possible?
this.LinkText = oLinkStyle;
}
protected override Style EvaluateCondition(object sourceDataObject, object sourceDataValue)
List<string> oList = (List<string>)sourceDataObject;
if (oList[0].StartsWith("Pro"))
return this.LinkText;
return null; // leave it unstyled;
I also noticed that ConditionalFormattingCellControl doesn't have a way to set TextDecoration to Underline.
So, how can I set Cursors = Hand and underline to a Conditional Formatting dell control?.
Rodolfo.
I solved it by have two separate syle control (UnderlinedStyle1 and UnderlineStyle2)
When I tried this, the PMOID and Order_Num data shows up in the same cell?
<navigation:Page.Resources> <Style x:Key="UnderlinedStyle" TargetType="ig:ConditionalFormattingCellControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ig:ConditionalFormattingCellControl"> <RichTextBox> <Paragraph> <Underline> <Run Text="{Binding PMOID}"/> <Run Text="{Binding Order_Num}"/> </Underline> </Paragraph> <RichTextBox.Style> <Style TargetType="RichTextBox"> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Foreground" Value="blue"/> <Setter Property="Cursor" Value="Hand"/> </Style> </RichTextBox.Style> </RichTextBox> </ControlTemplate> </Setter.Value> </Setter> </Style> </navigation:Page.Resources>
Private Sub XamGrid1_InitializeRow(sender As Object, e As Infragistics.Controls.Grids.InitializeRowEventArgs) Handles XamGrid1.InitializeRow Try Dim xrow As Row = e.Row If xrow IsNot Nothing Then If xrow.Cells("PMOID").Value <> "" Then Me.XamGrid1.ConditionalFormattingSettings.AllowConditionalFormatting = True Dim rule As New EqualToConditionalFormatRule rule.StyleScope = StyleScope.Cell rule.StyleToApply = TryCast(Me.Resources("UnderlinedStyle"), Style) rule.Value = xrow.Cells("PMOID").Value Me.XamGrid1.Columns.DataColumns("PMOID").ConditionalFormatCollection.Add(rule) rule = Nothing End If If xrow.Cells("Order_Num").Value <> "" Then Me.XamGrid1.ConditionalFormattingSettings.AllowConditionalFormatting = True Dim rule As New EqualToConditionalFormatRule rule.StyleScope = StyleScope.Cell rule.StyleToApply = TryCast(Me.Resources("UnderlinedStyle"), Style) rule.Value = xrow.Cells("Order_Num").Value Me.XamGrid1.Columns.DataColumns("Order_Num").ConditionalFormatCollection.Add(rule) rule = Nothing End If End If Catch ex As Exception Dim msg As String = ex.Message End Try End Sub
You can use the same key of the style for another (same type) column, or if you remove the key from the style entirely, it will apply to all columns of the same type.
The example is good; however, how do I get two or more columns to have the data underline (hyperlink) effect?
Hi Rodolfo,
I am attaching the same sample here as I provided you with in the case. The style is defined in XAML and referenced in code behind. It uses RichTextBox in ControlTemplate where you are able to set a text as underlined with other styles available as well.
Thank you,Sam