BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi SXTrader,
Thank you for using
Syncfusion Products.
We have analyzed your query. We have prepared the sample
to set the row background based on the MVVM pattern but we are not getting any
exception. Could you please check this sample and if you still got the exception,
please modify this sample along with the replication procedure? This would be helpful
to provide a better solution.
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/SfGrid_StyleSelector228717480.zip
Please let us know if you have any other queries.
Thank you,
Jai Ganesh S
Hi SXTrader,
Sorry for the inconvenience caused.
We have checked the reported issue with our sample but we are unable to reproduce the issue and it worksfine in our end. Could you please check the name space and dlls are added properly in your project?We have also attached the sample and video for your reference,
Video Link: http://www.syncfusion.com/downloads/support/directtrac/137224/VirtualizingIssue599575384.zip
Please let us know if you have any other queries.
Thank you,
Jai Ganesh S
Hi SXTrader,
Sorry for the inconvenience caused.
We have analyzed your issue and we found that we are having “VirtualizingCellsControl” class in both Syncfusion.UI.Xaml.Grid (present in Syncfusion.SfGrid.Wpf.dll) and Syncfusion.Windows.Controls.Cells (Present in Syncfusion.Grid.Wpf.dll) namespaces. The provided sample refer to both Syncfusion.SfGrid.Wpf.dll and also Syncfusion.Grid.Wpf.dll. Hence both namespaces are added to the below schema “http://schemas.syncfusion.com/wpf” in your application. So this designer shows errors. However you can overcome this problem by creating the separate namespace of SfDataGrid and use that namespace in VirtualizingCellsControl class.
xmlns:sfgrid="clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF"
<Style x:Key="gridRowBet" TargetType="sfgrid:VirtualizingCellsControl"> <Style.Triggers> <DataTrigger Binding="{Binding HasBet}" Value="True"> <Setter Property="Background" Value="Red"/> </DataTrigger> </Style.Triggers> </Style> |
We have also modified your sample based on this and you can download the sample from the below location,
Sample: http://www.syncfusion.com/downloads/support/directtrac/141954/ze/SXTippster_exampl_modifed1044293574
Please let us know if you need further assistance.
Thank you,
Jai Ganesh S
I am having the same issue. I looked at your example, and in your example, you are using <Window.Resources>.
However, I am attempting to do this in a UserControl and in UserControl.Resources there is no property for background.
How would I access a background property for the SfDataGrid in a UserControl?
Alternatively, if I need to access the cell background property with a style inside the SfDataGrid, how would I invoke a converter?
Ultimately, I need to change the background of the row conditionally based on a DateTime conditional statement.
Hi Timothy D Jones,
Your reported issue occurs due to
both Syncfusion.SfGrid.WPF and Syncfusion.Grid.WPF
or Syncfusion.GridCommon.WPF dlls are present in the common
namespace http://schemas.Syncfusion.com/wpf. Also, VirtualizingCellsControl
control is present in both the dlls with the same name, it leads to
Cannot find the Style Property 'Background' on the type reference exception
if you reference http://schemas.Syncfusion.com/wpf to your project.
You can resolve the reported problem by declaring the namespace for VirtualizingCellsControl
explicitly by specifying the assembly as below,
xmlns:syncfusionSfDataGrid=”clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF”
Please refer to the below code snippet,
<UserControl x:Class="Toolkit.ToDo.Views.ToDoView" xmlns:syncfusion=http://schemas.syncfusion.com/wpf xmlns:syncfusionSfDataGrid="clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:prism=http://prismlibrary.com/ xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:local="clr-namespace:Toolkit.ToDo.Views" mc:Ignorable="d" d:Background="White" d:Height="680" d:Width="500" prism:ViewModelLocator.AutoWireViewModel="True">
<UserControl.Resources> <local:ColorConverter x:Key="converter"/> <Style x:Key="rowStyle" TargetType="syncfusionSfDataGrid:VirtualizingCellsControl"> <Setter Property="Background" Value="Blue"/> </Style> </UserControl.Resources> </UserControl> |
For more information related to ambiguous type reference
exceptions, please refer to the below knowledge base documentation link,
KB Link: https://www.syncfusion.com/kb/5712/how-to-resolve-ambiguous-type-reference-exception
Please find the modified sample in the attachment and let us know if you have
any concerns in this.
Regards,
Vijayarasan S
If this post is helpful, please consider Accepting it as the solution so that other
members can locate it more quickly.