Home Forums WPF controls Xceed DataGrid for WPF Custom Converter help with binding

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26632 |

    First off, I know this is probably something simple, but using the samples as a guide, everything I have looks to be the same so I’m not sure what I’m missing.

    I’m binding to a DataTable. I have a column in the data thats a filetime. I simply wish to take in that 64 bit number and convert it to a DateTime so that you see a custom localized time string in the column instead of the 64bit number.

    I see all my rows of data just fine, but the conversion only receives “” as the object to convert. I cannot figure out why its passing in an empty string.

    Any help would be appreciated.

    <local:LongToStringTimeConverter x:Key=”timeConverter”/>
    <DataTemplate x:Key=”timeCellContentTemplate”>
    <TextBlock Text=”{Binding Converter={StaticResource timeConverter}}”/>
    </DataTemplate>
    <xcdg:DataGridCollectionViewSource x:Key=”records”
    Source=”{Binding Source={x:Static Application.Current},Path=Records}”>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <xcdg:DataGridItemProperty Name=”StartTime”/>
    <xcdg:DataGridItemProperty Name=”Duration”
    </xcdg:DataGridCollectionViewSource.ItemProperties>
    </xcdg:DataGridCollectionViewSource>

    <xcdg:DataGridControl x:Name=”dataGrid” Background=”White” Grid.Column=”1″ Grid.Row=”1″ ItemsSource=”{Binding Source={StaticResource records}}”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”StartTime”
    Title=”Start Time”
    CellContentTemplate=”{StaticResource timeCellContentTemplate}”
    VisiblePosition=”0″ />
    <xcdg:Column FieldName=”Duration”
    Title=”Duration” />
    </xcdg:DataGridControl.Columns>
    <xcdg:DataGridControl.View>
    <xcdg:TableView FixedColumnSplitterWidth=”6″ ShowRowSelectorPane=”False” VerticalGridLineThickness=”0″></xcdg:TableView>
    </xcdg:DataGridControl.View>
    </xcdg:DataGridControl>

    Imported from legacy forums. Posted by Mark (had 1948 views)

    User (Old forums)
    Member
    Post count: 23064

    As with most issues, after getting away from it for a few hours, I found my error. It was in the value converter itself, the above code works just lovely for those who might run into something similar.

    Thanks

    Imported from legacy forums. Posted by Mark (had 2894 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.