- Home
- Forum
- Xamarin.Forms
- Cannot set DisplayBinding on column from XAML
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}}"
MappingName="address"
DisplayBinding="{Binding address, Converter={StaticResource addressDisplayConverter}}"
Are there any workarounds for this in XAML?
SIGN IN To post a reply.
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.
Bugzilla Link: https://bugzilla.xamarin.com/show_bug.cgi?id=47703#c0
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
Hi John WieseThanks 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
SIGN IN To post a reply.
- 5 Replies
- 4 Participants
-
AH Assem Hakmeh
- May 23, 2017 07:17 AM UTC
- Mar 2, 2018 01:07 PM UTC