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

Custom background in border?

2 Answers 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 20 Aug 2010, 04:22 PM
I started with the Telerik WPF Q2 2010 examples.
I went to Controls -> DATA -> GridView -> Appearance -> Custom Row Layout

I am using a slightly modified version of this now.  What I want is to change the four gradient stops for the main row background dynamically based on object properties of the binding.  The problem is that my template is 75 lines long and I think it seems very inefficient to duplicate this six times (for siz possible gradient values) and use a TemplateSelector.  Instead I'd like to modify the border background property.

Here's a small snippet of code:

<ControlTemplate x:Key="TCCustomRowTemplate" TargetType="telerik:GridViewRow">
    <Border x:Name="rowsContainer" Background="#FF525252" Padding="8,8,8,0" >
        <Border x:Name="selectedRow" BorderThickness="1" BorderBrush="#FF000000" 
            Background
="{StaticResource TC_INRowBackgroundSelected}>

How can I modify this background to be a different static resource dependant on my object?

2 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 23 Aug 2010, 09:28 PM
For the time being, I created six different templates, six different styles, and a style selector.   That's working fine, I just wish I could figure out how to create a <Border.Triggers> secton and set a background based on the object's properties.
0
Accepted
Milan
Telerik team
answered on 24 Aug 2010, 07:54 AM
Hi Paul,

There might be an easier way to do that instead of redefining the whole template. The first option is to use the so called Style/Template selectors which allow you to apply a different row style based on your own logic. More information about this technique can be found here

As demonstrated here, the other alternative is to use some sort of behavior that will do the styling for you.

Hope this helps.

Sincerely yours,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Milan
Telerik team
Share this question
or