We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Cannot set DisplayBinding on column from XAML

     When attempting to set the DisplayBinding property from XAML. The XAML compiler reports a property not found error.

                    <sf:GridTextColumn
                        MappingName="address"
                        DisplayBinding="{Binding address, Converter={StaticResource addressDisplayConverter}}"


Are there any workarounds for this in XAML?


5 Replies

SS Sivaraman Sivagurunathan Syncfusion Team May 24, 2017 11:38 PM UTC

Hi Assem Hakmeh, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. In that, if you are enabling the Xaml compilation in code behind ([XamlCompilation(XamlCompilationOptions.Compile)]) you cannot set the binding in XAML page. This is a known issue in the Framework and has been reported as a bug in Bugzilla as well. You can see the details of it from the below thread. 
 
 
However, you can overcome this issue as of now by setting DisplayBinding for the columns in code-behind instead of Xaml.  
 
Please refer the below code snippet.  
  
// In Xaml  
<syncfusion:SfDataGrid x:Name="dataGrid"  
                           AutoGenerateColumns="False"  
                           ColumnSizer="Star"  
                           ItemsSource="{Binding OrdersInfo}">  
        <syncfusion:SfDataGrid.Columns>    
           <syncfusion:GridTextColumn MappingName="OrderID" />         
        </syncfusion:SfDataGrid.Columns>  
</syncfusion:SfDataGrid>  
  
// In Codebehind  
dataGrid.Columns[0].DisplayBinding = new Binding() { Path = "OrderID", Converter = newDisplayBindingConverter() };  
  
Also, we have attached a simple sample for your reference and you can download the same from the below link.  
 
 
Regards, 
Sivaraman 
 



JW John Wiese February 26, 2018 04:07 PM UTC

Reviewing the Bugzilla report it appears that the Xamarin team suggested that there is a change needed in sfDataGrid.  In the latest update (Feb. 2018) I still receive the error when setting the DisplayBinding in XAML.  Is this a change you plan to make or are my only options to disable XAML-Compilation or set the DisplayBinding in code?


SS Sivaraman Sivagurunathan Syncfusion Team February 28, 2018 03:35 AM UTC

Hi John Wiese 
 
Thanks for using Syncfusion support. 
 
We have checked your query. In Bugzilla report, they suggest to use BindingBase instead binding. If we are using BindingBase instead of using Binding typecast has been occur for each GridCell in SfDataGrid. So we should suggest you to set the DisplayBinding in code behind. Or if you want to maintain the MVVM pattern write the behavior to the SfDataGrid and set the DisplayBinding.  
 
Regards, 
Sivaraman 
 



AH Assem Hakmeh replied to Sivaraman Sivagurunathan February 28, 2018 04:48 AM UTC

Hi John Wiese 
 
Thanks for using Syncfusion support. 
 
We have checked your query. In Bugzilla report, they suggest to use BindingBase instead binding. If we are using BindingBase instead of using Binding typecast has been occur for each GridCell in SfDataGrid. So we should suggest you to set the DisplayBinding in code behind. Or if you want to maintain the MVVM pattern write the behavior to the SfDataGrid and set the DisplayBinding.  
 
Regards, 
Sivaraman 
 


Hi Sivaraman,

Are you saying that your team has chosen DisplayBinding to be of type Binding instead of BindingBase for performance reasons? Because the cost of type-casting BindingBase to Binding is too high? If that is the case, can you please share any measurements you would have to compare the two?

Sincerely,

Assem


SK Suriya Kalidoss Syncfusion Team March 2, 2018 01:07 PM UTC

Hi JohnWiese, 
    
We have created an incident under your account regarding your query for further follow-ups and you can track the status of the requirement on this incident 199999. 
Regards, 
Suriya 
  


Loader.
Live Chat Icon For mobile
Up arrow icon