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

RadSpreadSheet issue if used inside a DataTemplate

1 Answer 99 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Atul
Top achievements
Rank 1
Atul asked on 17 Apr 2019, 08:03 AM

Hi i'm using RadSpreadSheet inside a ControlTemplate and binding the control with Workbook property.

But it's not getting affected, whenever my binding is changed it does not get refreshed inside the control and the UI is not rendered.

And if i manually change the binding property at run time in xaml, then the control gets the binded and renders the data it on UI.

 

I have attached the code of the control in which i'm using the RadSpreadSheet.

1 Answer, 1 is accepted

Sort by
0
Nikolay Demirev
Telerik team
answered on 22 Apr 2019, 07:54 AM
Hello Atul,

I have reproduced this issue and I have found it is already logged and here is the public item in the Feedback portal https://feedback.telerik.com/wpf/1354098. You could follow it in order to receive notifications when we start working on it and release a fix.

As a possible workaround I could suggest you create attached property and use it to bind you ViewModel and update the RadSpreadsheet property using it. Here is an example implementation:
public static class SpreadsheetExtensions
{
    public static Workbook GetBindableWorkbook(DependencyObject obj)
    {
        return (Workbook)obj.GetValue(BindableWorkbookProperty);
    }
 
    public static void SetBindableWorkbook(DependencyObject obj, Workbook value)
    {
        obj.SetValue(BindableWorkbookProperty, value);
    }
 
    // Using a DependencyProperty as the backing store for Workbook.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty BindableWorkbookProperty =
        DependencyProperty.RegisterAttached("BindableWorkbook", typeof(Workbook), typeof(RadSpreadsheet),
            new PropertyMetadata(OnBindableWorkbookPropertyChanged));
 
    private static void OnBindableWorkbookPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        RadSpreadsheet radSpreadsheet = d as RadSpreadsheet;
 
        if (radSpreadsheet != null)
        {
            radSpreadsheet.Workbook = e.NewValue as Workbook;
        }
    }
}

and then in XAML:
<telerik:RadSpreadsheet local:SpreadsheetExtensions.BindableWorkbook="{Binding Path=Workbook}" />

I hope this works for you.

Regards,
Nikolay Demirev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Spreadsheet
Asked by
Atul
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
Share this question
or