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?
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
0
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
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.
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
Hi,
Vlad
the Telerik team
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.
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
Hi,
Didie
the Telerik team
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 >>