Fontcolor converter problem

Hi 

I have a grid that font color converter behaves weird

this is the column 
     <sf:GridTextColumn x:Name="colSubject" MappingName="v_subject"  ShowToolTip="True" IsHidden="True" HeaderText="Subject" >
                    <sf:GridTextColumn.CellStyle>
                        <Style TargetType="sf:GridCell">
                            <Setter Property="BorderThickness" Value="0.3" />
                            <Setter Property="BorderBrush" Value="#dcdcdc" />
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <MultiBinding Converter="{StaticResource fontColorConverterMULTI}" Mode="TwoWay">
                                        <Binding Path="n_status" />
                                        <Binding Path="v_text_color" />
                                    </MultiBinding>
                                </Setter.Value> </Setter>
                            <Setter Property="FontWeight" Value="{Binding Path=n_status, Mode=TwoWay, Converter={StaticResource fontWeightConverter}}" />
                        </Style>
                    </sf:GridTextColumn.CellStyle>
                </sf:GridTextColumn>

and this is the converter
 public class FontColorConverterMULTI : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null)
                return DependencyProperty.UnsetValue;
            //new AGW_DEBUG.AGWDebugLog("values=" + values.Length);
            foreach (var item in values)
            {
                if (item == null)
                    continue;
                if (item.GetType() == typeof(int))
                {
                    if ((int)item == (int)LeftTreeAccounts.MAILSTATUS.MAILSTATUS_UNREAD)
                    {
                        System.Diagnostics.Debug.WriteLine("return BlueViolet");
                        return new SolidColorBrush(Colors.BlueViolet);
                    }
                }
                if (item.GetType() == typeof(string))
                {
                    string strTextColor = (string)item;
                    if (string.IsNullOrEmpty(strTextColor))
                        return DependencyProperty.UnsetValue;
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("return "+ strTextColor);
                        return (new BrushConverter().ConvertFromString(strTextColor)) as SolidColorBrush;
                    }
                }
            }
            return DependencyProperty.UnsetValue;
        }
        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }

it always shows black color although from debugging I can see that returns different color brushes

Thank you for the help in advance

George


4 Replies

DY Deivaselvan Y Syncfusion Team September 17, 2018 01:14 PM UTC

Hi George,

Thank you for contacting Syncfusion support.

We are unable to reproduce the reported issue with foreground color when its applied from the converter. We have attached the sample which we have tried to reproduce the reported issue with the given code sample and please find the testing sample from the below link.

Sample link:
TimeSpan-17809126651024688280.zip

On analyzing further with your code example, we could found that you have set the IsHidden property as true for GridTextColumn. We are afraid on how you could find the foreground issue with the hidden column because in this case column won’t be comes into View. So, could you please provide more details on your application implementation with your interactions to the DataGrid control. Also modify the above sample based on your working scenario and revert us with the replication procedure to reproduce the issue at our end, thereby we could provide appropriate details at the earliest.

Regards,
Deivaselvan 



GR George Rossopoulos September 17, 2018 01:19 PM UTC

Hi

isHidenn flag is controlled by software so is not the case.
In this case in the same grid this cell works fine

        <sf:GridTemplateColumn  x:Name="gridRow" TextWrapping="NoWrap" HeaderText="" sf:FocusManagerHelper.WantsKeyInput="True">
                    <sf:GridTemplateColumn.CellTemplate >
                        <DataTemplate >
                            <Grid Height="55" Margin="0,0,10,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="140"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel >
                                    <TextBlock Padding="1" Text="{Binding Converter={StaticResource fromAddrConverter}}"
                                               FontSize="16"
                                               FontFamily="Segoe UI"></TextBlock>
                                    <TextBlock Padding="1" Text="{Binding v_subject}"
                                               Foreground="{Binding Path=n_status, Mode=TwoWay, Converter={StaticResource fontColorConverter}}"
                                               FontWeight="{Binding Path=n_status, Mode=TwoWay, Converter={StaticResource fontWeightConverter}}"
                                               TextWrapping="WrapWithOverflow"
                                               FontSize="14">
                                    </TextBlock>
                                </StackPanel>
                                <StackPanel Margin="5,3,0,0" Grid.Column="1">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="20"/>
                                            <ColumnDefinition Width="20"/>
                                            <ColumnDefinition Width="20"/>
                                            <ColumnDefinition Width="20"/>
                                        </Grid.ColumnDefinitions>
                                        <Image x:Name="imgReply"  Width="16" Height="16" Source="{Binding Converter={StaticResource statusConverter}}" />
                                        <Image  x:Name="imgPriority" Width="16" Height="16" Grid.Column="1" Source="{Binding Converter={StaticResource priorityConverter}}"/>
                                        <Image  x:Name="imgother"  Width="16" Height="16" Grid.Column="2"/>
                                        <Image x:Name="imgAttach" Width="16" Height="16" Source="{Binding Converter={StaticResource attachmentConverter}}" Grid.Column="3"/>
                                    </Grid>
                                    <TextBlock Padding="1" Text="{Binding Converter={StaticResource dateRcvdConverter}}"
                                               FontSize="12" FontFamily="Segoe UI" FontWeight="Regular">
                                    </TextBlock>
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </sf:GridTemplateColumn.CellTemplate>
                </sf:GridTemplateColumn>

Thank you



GR George Rossopoulos September 17, 2018 05:41 PM UTC

Hi

just for your info I solved my problem replacing the  GridTextColumn with GridTemplateColumn with TexBlock inside

Thank You
George
 




DY Deivaselvan Y Syncfusion Team September 19, 2018 03:57 AM UTC

Hi George,

Thank you for the update. We are happy to hear that you have meet your requirement using GridTemplateColumn. Please let us know if you need any further assistance.

Regards,
Deivaselvan 


Loader.
Up arrow icon