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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to specify custom style for checkbox which is in sfDataGrid cell

Thread ID:

Created:

Updated:

Platform:

Replies:

129255 Mar 7,2017 12:39 PM UTC Mar 15,2017 03:49 AM UTC UWP 5
loading
Tags: SfDataGrid
Xavier
Asked On March 7, 2017 12:39 PM UTC

I use the sfDataGrid to show data. There's a checkbox control in per row. It works well.

Now, I want to change checkbox's background, I specify my custom style for it, but it didn't work.

You can see my xaml code:

<Page.Resources>
        <Style x:Key="CheckBoxStyle1" TargetType="CheckBox">
            <Setter Property="Background" Value="Red"/>
        </Style>
        <DataTemplate x:Key="cellTemplate">
            <CheckBox Content="abc" IsChecked="{Binding IsChecked}" Style="{StaticResource CheckBoxStyle1}"></CheckBox>
        </DataTemplate>
    </Page.Resources>
    <Page.DataContext>
        <local:ViewModel />
    </Page.DataContext>

    <Grid>

        <syncfusion:SfDataGrid x:Name="dataGrid"
                       AllowFiltering="True"
                       ItemsSource="{Binding Orders}">
            <syncfusion:SfDataGrid.Columns>
                <syncfusion:GridTextColumn HeaderText="Order ID" MappingName="OrderID" />

                <syncfusion:GridTextColumn HeaderText="Customer ID" MappingName="CustomerID" />

                <syncfusion:GridTemplateColumn MappingName="IsChecked" CellTemplate="{StaticResource cellTemplate}">
                </syncfusion:GridTemplateColumn>
                <syncfusion:GridTextColumn HeaderText="Customer Name"

MappingName="CustomerName" />
            </syncfusion:SfDataGrid.Columns>
        </syncfusion:SfDataGrid>
    </Grid>

Muthukumar Kalyanasundaram [Syncfusion]
Replied On March 8, 2017 05:43 PM UTC

Hi Xavier, 

Thank you for contacting Syncfusion support. 

We have checked your code.  You have set the custom style for checkbox control, the style are applied to CheckBox control in GridTemplateColumn. For your reference, we have attached the sample in below location. 


If you want to apply style for  checkbox rectangle, you need to override the checkbox control style and change background for that rectangle instead set background for entire checkbox control. 

Please let us know if you have any query. 

Regards, 
Muthukumar K 


Xavier
Replied On March 10, 2017 02:16 AM UTC

Thank you Muthukumar K !

I found a strage scenario. If I install your syncfusion library via ".exe" and add reference to it directly. Then I use your code will not work.

But if I add Package source in visual studio and use NuGet package manager to install your package in my project, then your code will work.

That's why?

Muthukumar Kalyanasundaram [Syncfusion]
Replied On March 10, 2017 06:20 PM UTC

Hi Xavier, 
 
We have checked your query. We are not able to reproduce the reported issue, it’s working fine in our end. Could you please provide your current Syncfusion product version, it will helpful for us to analyze further. 
 
Regards, 
Muthukumar K 


Xavier
Replied On March 13, 2017 01:33 AM UTC

Hi Xavier, 
 
We have checked your query. We are not able to reproduce the reported issue, it’s working fine in our end. Could you please provide your current Syncfusion product version, it will helpful for us to analyze further. 
 
Regards, 
Muthukumar K 


Thanks for your help.

The library version is: 14.4.0.15



Attachment: AppDataGrid_636c5dc6.zip

Muthukumar Kalyanasundaram [Syncfusion]
Replied On March 15, 2017 03:49 AM UTC

Hi Xavier, 

We have analyzed the provided sample. It seems CheckBox style not working as expected only when setting TargetVersion as Windows 10 Anniversary Edition.  

 
The same working when setting any other target version as in the below code snippet,
 

It is not an issue with Syncfusion control. This issue was reproduced when using CheckBox alone in application also.  

Please let us know if you have any query. 

Regards, 
Muthukumar K 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;