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

Bindning to another element property from AlternateRowStyle

6 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Licensing
Top achievements
Rank 1
Licensing asked on 29 Mar 2012, 10:22 AM
Hello.

I have a RadGridView. And a fake element below. I want to bind AlternativeRowBackground to fake element Background property. And I want to do so in AlternativeRowStyle (because in code-behind this style is upgraded with other triggers, that change Background property due to some logic) and not in AlternativeRowBackground property.
 
Is it possible to do so somehow? 

<telerik:RadGridView ItemsSource="{Binding Data}" AlternationCount="2">
    <telerik:RadGridView.AlternateRowStyle>
        <Style TargetType="telerik:GridViewRow">
            <Setter Property="Background" Value="{Binding ElementName=FakeButton, Path=Background}"/>
        </Style>
    </telerik:RadGridView.AlternateRowStyle>
</telerik:RadGridView>
<Button x:Name="FakeButton" Background="Blue" Content="Button" />

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 29 Mar 2012, 11:52 AM
Hello,

Element name binding to elements outside RadGridView is not recommended at row level. The reason - rows are virtualized for scrolling performance reasons. Rows/cells are dynamically being added,reused and recycled thus tampering the namescope.

As an alternative I would offer to expose your relevant property as a property of some static resource object. using binding to a static resource source object is much more reliable  from within the rows.

Greetings,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Licensing
Top achievements
Rank 1
answered on 29 Mar 2012, 12:46 PM
Thank you for your answer.

For better understanding, why I want to bind to another element, let me tell yoy a prehistory. In my application I have grids, multiple themes and settings to adjust grid's colors. If settings are not adjusted I should use the colors from theme. The settings are binded to grid properties in XAML. If the property from settings is null the relevant property in grid is also null, but i need it to have the value from current theme. For this reason I create trigger that if the property from settings is null binds it to invisible fake element's relevant property.    

May be you can tell me better solution for this problem.
0
Licensing
Top achievements
Rank 1
answered on 19 Apr 2012, 07:54 AM
Any feedback?
0
Vlad
Telerik team
answered on 19 Apr 2012, 08:08 AM
Hi,

 Maybe it will be better to store/use the color from a StaticResource. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Licensing
Top achievements
Rank 1
answered on 19 Apr 2012, 12:39 PM
Hello!

As I've explained above we can't use static resources.

Can you provide me with any solution, how can I use RadGridView for the application with the following requirements:
1) application supports multiple themes
2) user can adjust settings of the grid (such as colors, fonts etc.) himself
3) If grid settings are not adjusted the appearance of the grid must be according to chosen theme.

Or tell me if it is impossible.
0
Dimitrina
Telerik team
answered on 23 Apr 2012, 09:17 AM
Hi,

I have attached a sample project on how you could change the theme of your RadGridView.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Licensing
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Licensing
Top achievements
Rank 1
Vlad
Telerik team
Dimitrina
Telerik team
Share this question
or