This is a migrated thread and some comments may be shown as answers.

[Solved] CellDecorationStyleSelector

6 Answers 231 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alfred
Top achievements
Rank 1
Alfred asked on 02 May 2013, 10:26 PM
I am attempting to format the cells of a grid using the CellDecorationStyleSelector. Everything appears to work fine until I scroll up and down the grid.  As I do that the grid formatting changes, and is no longer set to the values set by my formatting with the CellDecorationStyleSelector.  Please let me know if this is a known issue.  Below is the relevant portion of my Xaml code.

Thanks,
Al


< common:ProjectStyleSelector x:Key="ProjectBackStyleSelector">
                    <common:ProjectStyleSelector.Level0>
                        <Style TargetType="Rectangle">
                            <Setter Property="Fill" Value="AliceBlue"/>
                        </Style>
                    </common:ProjectStyleSelector.Level0>
                    <common:ProjectStyleSelector.Level1>
                        <Style TargetType="Rectangle">
                            <Setter Property="Fill" Value="SteelBlue"/>
                        </Style>
                    </common:ProjectStyleSelector.Level1>
                    <common:ProjectStyleSelector.Level2>
                        <Style TargetType="Rectangle">
                            <Setter Property="Fill" Value="LightSteelBlue"/>
                        </Style>
                    </common:ProjectStyleSelector.Level2>                   
                </common:ProjectStyleSelector>
                <common:ProjectStyleSelector x:Key="ProjectStyleSelector">                   
                    <common:ProjectStyleSelector.Level0>
                        <Style TargetType="TextBlock">
                            <Setter Property="FontWeight"
                                Value="ExtraBlack" />
                            <Setter Property="Foreground"
                                Value="Black" />
                            <Setter Property="FontSize"
                                Value="20" />
                            <Setter Property="Margin"
                                Value="0,0,0,0" />
                        </Style>
                    </common:ProjectStyleSelector.Level0>
                    <common:ProjectStyleSelector.Level1>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground"
                                Value="Black" />
                            <Setter Property="Margin"
                                Value="5,0,0,0" />
                        </Style>
                    </common:ProjectStyleSelector.Level1>
                    <common:ProjectStyleSelector.Level2>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground"
                                Value="Black" />
                            <Setter Property="Margin"
                                Value="10,0,0,0" />
                        </Style>
                    </common:ProjectStyleSelector.Level2>                   
                </common:ProjectStyleSelector>

< Grid:RadDataGrid.Columns>
                    <Grid:DataGridTextColumn PropertyName="TaskOutlineLevel" Header="L" SizeMode="Auto" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />
                    <Grid:DataGridTextColumn PropertyName="TaskOutlineNumber" Header="Outline" SizeMode="Auto" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}"/>
                    <Grid:DataGridTextColumn PropertyName="TaskIsSummary" Header="Smry" SizeMode="Auto" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />
                <Grid:DataGridTextColumn PropertyName="TaskName" Header="Task Name" CellContentStyleSelector="{StaticResource ProjectStyleSelector}" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />
                    <Grid:DataGridTextColumn PropertyName="TaskStartDate" CellContentFormat="{}{0:MM/dd/yyyy}" SizeMode="Auto" Header="Start" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />
                    <Grid:DataGridTextColumn PropertyName="TaskFinishDate" CellContentFormat="{}{0:MM/dd/yyyy}" SizeMode="Auto" Header="Finish" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />
                    <Grid:DataGridTextColumn PropertyName="TaskReaminingWork" CellContentFormat="{}{0,0:N0}" SizeMode="Auto" Header="Reamining Work" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}"/>
                    <Grid:DataGridTextColumn PropertyName="TaskPercentWorkCompleted" CellContentFormat="{}{0:N0}" SizeMode="Fixed" Width="100" Header="% Work Completed" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}"/>
                    <Grid:DataGridTextColumn PropertyName="TaskWork" CellContentFormat="{}{0,0:N0}" SizeMode="Auto" Header="Work" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}"/>
                    <Grid:DataGridTextColumn PropertyName="TaskActualCost" CellContentFormat="{}{0,0:N0}" SizeMode="Auto" Header="Actual Work" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}"/>
            </Grid:RadDataGrid.Columns>

6 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 03 May 2013, 02:22 PM
Hi Alfred,

Thank you for contacting us.

I tried to reproduce this issue locally, but with no result. I have prepared an example, that uses both the CellDecorationStyleSelector and CellContentStyleSelector, and it is working as expected. Can you please check this project and try to reproduce the described issue?

I am looking forward to your reply.

All the best,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Alfred
Top achievements
Rank 1
answered on 03 May 2013, 02:54 PM
I took at look ate your example.

The line below in your code returns an error that "Value" is an unknown member.

Please advise.

Thank you.

string cellContent = (item as DataGridCellInfo).Value.ToString();

0
Alfred
Top achievements
Rank 1
answered on 03 May 2013, 03:47 PM
It appears that the CellDecorationStyleSelector does not work consistently when the cell also uses CellContentFormat.  Please the attached image as an example.

THIS WORKS

<Grid:DataGridTextColumn PropertyName="TaskOutlineLevel" Header="L" SizeMode="Auto" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}"/>

<Grid:DataGridTextColumn PropertyName="TaskOutlineNumber" Header="Outline" SizeMode="Auto" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />

<Grid:DataGridTextColumn PropertyName="TaskName" Header="Task Name" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />


THIS DOES NOT 
<Grid:DataGridTextColumn PropertyName="TaskStartDate" CellContentFormat="{}{0:MM/dd/yyyy}" SizeMode="Auto" Header="Start" CellDecorationStyleSelector="{StaticResource ProjectBackStyleSelector}" />

0
Ivaylo Gergov
Telerik team
answered on 06 May 2013, 08:11 AM
Hi Alfred,

The Value property is available with our Q1 2013 SP1 release. I can see that you are currently using the Q1 2013 official release, so that is why it causes build errors. I have modified the example in order to match this version.

In addition, the attached example shows a RadDataGrid with one column that uses both the CellContentStyleSelector and the CellDecorationStyleSelector properties with combination of CellContentFormat and it is working correctly. Can you try to reproduce the described issue? From the given snapshot, I guess there is a problem with the current logic that the ProjectBackStyleSelector class implements.

I am looking forward to your reply.

Greetings,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Alfred
Top achievements
Rank 1
answered on 10 May 2013, 09:31 PM
I applied the custom setting from the test project that you sent and the result were essentially the same.  I have attached a screen capture as evidence.

Thanks,
Al
0
Ivaylo Gergov
Telerik team
answered on 13 May 2013, 03:40 PM
Hello Alfred,

Is it possible for you to send me your project or to prepare a demo application that reproduces the wrong behavior so that I can further help you with this issue? Please note, that you will need to open a new support ticket rather than forum post to enable file attachments.

I am looking forward to your reply.

Regards,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Grid for XAML
Asked by
Alfred
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Alfred
Top achievements
Rank 1
Share this question
or