Unplanned
Last Updated: 21 Mar 2023 12:55 by ADMIN
ADMIN
Lance | Senior Manager Technical Support
Created on: 19 Jan 2018 18:03
Category: Gauges
Type: Bug Report
1
Gauge: DynamicResource colors don't work for GaugeRange Color
Using a DynamicResource to set the GaugeRange Color property does not work:

<!-- does not work -->
<gauges:GaugeRange Color="{DynamicResource GrayBackgroundColor}" ... />

Using a StaticResource works as expected:

<!-- works -->
<gauges:GaugeRange Color="{StaticResource GrayBackgroundColor}" ... />

Side-Note:
Using DynamicResource for Indicator Fill works as expected.
2 comments
ADMIN
Lance | Senior Manager Technical Support
Posted on: 21 Mar 2023 12:55

Hi Peter,

Although this request is for the Chart properties, I can answer in the same context because the underlying topic is the same.

This is expected and designed behavior when attempting to use a DynamicResource with a CLR property. In order for a DynamicResource to work, it relies on the target property to be a BindableProperty (or 'DependencyProperty' in other XAML flavors).

The reason this is designed this way is for performance reasons. We choose to keep the properties of these style objects to be CLR properties. For example, the DataGridBorderStyle class's properties are not BindableProperties because that can have a severe performance issue in a UI virtualized panel like the DataGrid uses.

So, the trade-off for that performance means you need to replace the style property itself, rather than update the individual values of the style's properties. For example, make the entire style object updatable:

<!-- Do This -->
<RadDataGrid  RowBackgroundStyle="{Binding SomeDynamicSourceBasedOnConditions" />

<!-- instead of this -->
<RadDataGrid>
    <RadDataGrid.RowBackgroundStyle>
        <DataGridBorderStyle BackgroundColor="{DynamicResource someDynamicThing}"  .../>
    </RadDataGrid.RowBackgroundStyle>
</RadDataGrid>

Until the framework itself doesn't impose such performance penalty for the listeners of the BindableProperties, this is the best compromise that still lets you achieve your customizations goals. 

Regards,
Lance | Manager Technical Support
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Peter
Posted on: 21 Mar 2023 10:37
Any updates on this?

Experiencing this on RadDataGrid in Xamarin.