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

Question about StyleSelectors (Background Property not recognized)

Hello,
I'm trying to set the color of the border of a row in dependency of a value in the MVVM.
I found following documentation on your site: http://help.syncfusion.com/ug/wpf/default.htm#!documents/styleselectors.htm

Now I tried to translate this in a way I want to have:

<UserControl.Resources>
        <converters:BetMethodConverter x:Key="converterBetMethod" />
        <converters:NonRunnerConverter x:Key="nonRunnerImageConverter"/>       
        <Style x:Key="gridRowBetStyle" TargetType="syncfusion:VirtualizingCellsControl">
            <Style.Triggers>
                <DataTrigger Binding="{Binding HasBet}" Value="True">
                    <Setter Property="Background" Value="Bisque" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

But the IDE keeps telling me that the Property "Background" is not a element of Syncfusion.Windows.Controls.Cells.VirtualizingCellsControl.

Can you tell me what's wrong?

7 Replies

JG Jai Ganesh S Syncfusion Team February 13, 2015 12:52 PM UTC

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



DF Diego Fernando Urabayen April 27, 2015 12:22 PM UTC

The VirtualizingCellsControll property does not appear in my project. Can you help me?

Attachment: RowStyle.png_305f0721.zip


JG Jai Ganesh S Syncfusion Team April 28, 2015 02:31 PM UTC

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




SX SXTrader September 2, 2015 07:32 PM UTC

Hello,
could you please take a look into the attached example. For Some reason I've got this behaviour again.



Attachment: SXTippster_example_background_78df7217.zip


JG Jai Ganesh S Syncfusion Team September 3, 2015 09:08 AM UTC

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.dllHence 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



TD Timothy D Jones August 28, 2022 11:18 PM UTC

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. 



Attachment: Toolkit.ToDo_315aefcb.zip


VS Vijayarasan Sivanandham Syncfusion Team August 29, 2022 03:48 PM UTC

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.


Attachment: ModifiedSample_613732df.zip

Loader.
Live Chat Icon For mobile
Up arrow icon