I am disabling checkboxes in the grid. Setting IsEnabled to false. How do I make it look like a windows checkbox when disabled. You know, kind of grayed out.
Anybody?
Hi singlemalt,
What you've done, i.e. setting the IsEnabled to false, should do the trick.
Please check the attachment to see what I get using the following template:
<
ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
Could you, please let us know which NetAdvantage version you're using, and how your checkboxes appear?
Thanks.
I am using: 9.2.20092.2064
the checkbox on top is disabled, the one below is enabled.
I am doing it like this ( i am not using a control template):
<igDP:Field Name="MyFlag Label="MyFlag" Width="90"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamCheckEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamCheckEditor}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=DataItem.IsFlagEditable}" Value="false"> <Setter Property="IsReadOnly" Value="true" /> <Setter Property="IsEnabled" Value="false" /> </DataTrigger> </Style.Triggers> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
attached is the image
I see what you mean. I tested this at my end and here's the solution I found.
What you can is replacing the 2 setters:
<Setter Property="IsReadOnly" Value="true" />
<Setter Property="IsEnabled" Value="false" />,
with the following:
Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:XamCheckEditor}">
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="False" />
</ControlTemplate>
</Setter.Value>
</Setter>
Hope this helps.
That did it. Thanks.
There is one problem now. If the checkbox is checked (from binding), it does not appear gray and checked. If I go back to my original code where the checkbox is disabled and read-only, the box can still be checked from binding. Is there a way to display it as checked and disabled.
I apologize in advance because I'm not very sure I've got your idea.
Here's how I see it - you don't need to disable the checkbox only if its value is false anymore, but you need it disabled irrespective of the actual value. That's why I removed the trigger you use in your older posts. Then I have the following code which seems to work for this purpose:
<igDP:Field Name="Header1" Label="Flag" >
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamCheckEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamCheckEditor}">
<Style.Setters>
<Setter Property="Template">
<CheckBox HorizontalAlignment="Center" IsEnabled="False" IsChecked="{Binding Path=DataItem.Header1}"></CheckBox>
</Style.Setters>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
To clarify, it appears gray but not checked although the binding is true/checked.