So, I'm having a problem with a *check box* field not displaying the checkbox state correctly. IMO, it should either be checked or not. This image shows that the box is neither of those states... it's in some other tertiary state.
And here's the definition of the class that is passed to the DataContext for the XamDataGrid...
public class SampleGridItem : INotifyPropertyChanged{ public Int64 SkuOrUpc { get; set; } public String ItemDescription { get; set; } public Int32 Quantity { get; set; } public String UserName { get; set; } public Boolean IsFlex { get; set; } //...}
And the Property for getting/setting the DataContext...
public ObservableCollection<SampleGridItem> GridItems{ get { return DataContext as ObservableCollection<SampleGridItem>; } set { DataContext = value; }}
And the partial XAML definition...
<DataPresenter:XamDataGrid EditModeEnding="OnGridFieldValueChanged" SelectedItemsChanged="requestedLabelsGrid_SelectedItemsChanged" LostFocus="requestedLabelsGrid_LostFocus" GotFocus="requestedLabelsGrid_GotFocus" Name="requestedLabelsGrid" DataSource="{Binding}" RecordActivated="requestedLabels_RecordActivated" TabIndex="10" Theme="RoyaleStrong" GroupByAreaLocation="None"> <DataPresenter:XamDataGrid.FieldLayoutSettings> <DataPresenter:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True" MaxSelectedCells="1" MaxSelectedRecords="1" /> </DataPresenter:XamDataGrid.FieldLayoutSettings> <DataPresenter:XamDataGrid.FieldLayouts> <DataPresenter:FieldLayout> <DataPresenter:FieldLayout.Fields>
... <DataPresenter:Field Name="IsFlex" Label="Flex"> <DataPresenter:Field.Settings> <DataPresenter:FieldSettings CellMinWidth="0" CellMaxWidth="300" CellWidth="40" AllowEdit="False" LabelClickAction="SortByMultipleFields" AllowGroupBy="false"/> </DataPresenter:Field.Settings> </DataPresenter:Field> </DataPresenter:FieldLayout.Fields> </DataPresenter:FieldLayout>
</DataPresenter:XamDataGrid.FieldLayouts> </DataPresenter:XamDataGrid>
Everything works swimingly... except for the IsFlex field. So... what am I missing and why is the *IsFlex* field the only one not displaying correctly?
Thanks!
- Wil
Cool. I had tried using DataType="{x:Type sys:String}" and it didn't work. But using the EditAsType does work.
Try specifying a string editor. If I do this in a test, I get "True" or "False" as a string when binding to a bool. You should then be able to create a converter to show "Yes" or "No".
<igDP:Field.Settings>
<igDP:FieldSettings EditAsType="{x:Type sys:String}" />
</igDP:Field.Settings>
I have a similar issue. I'm trying to convert a boolean value to a yes/no field. I got the latest hotfix and the checkboxes are finally showing up correctly. But I want to use the grid to pass the boolean to a converter and get a string back of "Yes" or "No". I don't want to display a checkbox. I can't find a way to get the grid to think that the results of the converter are anything but a boolean. I can do converters that go from string to string. But I can't go from boolean to string.
This has been discussed a few times already. There was a bug that was fixed in the recent hotfix release. I assume you haven't installed that fix yet. There are also code snippets here if you poke around (search on checkboxes).