This is a migrated thread and some comments may be shown as answers.

Converter called twice with MultiBinding

3 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 30 Oct 2013, 04:53 PM
Since MultiBinding is not supported directly on GridViewDataColumns, I have the following:
<telerik:RadGridView ItemsSource="{Binding TestGridData}" Height="150" Margin="5" AutoGenerateColumns="False" ShowGroupPanel="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="StringValue">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate >
                    <TextBlock>
                        <TextBlock.Text>
                            <MultiBinding Converter="{view:TestConverter}">
                                <Binding Path="StringValue"/>
                                <Binding Path="IntValue"/>
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

This works absolutely fine but I have to cater for the converter being called more times than I'd expect when editing the underlying collection. If I have 5 rows of data then the converter is called 10 times. The last 5 times are for the 5 rows of data but the first 5 times are for 5 sets of DependencyProperty.UnsetValue being passed into the converter.

Looking at the callstack, this seems to be caused by a call to ClearRow in the GridViewRowItem which is eventually hit as part of the ItemsSourceChanged event.

Can anyone explain why the grid needs to clear every row before assigning the new value? This doesn't happen with a non-multi binding, the converter is only called 5 times after an edit. Is it something to do with the fact that I'm using a CellTemplate?

Cheers! :)

3 Answers, 1 is accepted

Sort by
0
Pete
Top achievements
Rank 1
answered on 04 Nov 2013, 09:20 AM
Only read the posting guidelines after posting! So have updated my account to be non-anonymous and include the following details:

    • WPF version - 4/VS2012
    • OS - Windows 7
    • exact browser version - IE 9.0.8112.16421
    • exact version of the Telerik product - 2013.2.724.40
    • preferred programming language (VB.NET or C#) C#

Cheers, Pete
0
Accepted
Ivan Ivanov
Telerik team
answered on 04 Nov 2013, 04:45 PM
Hello,

 RadGridVIew utilizes container recycling, so that at some point of the application's lifecycle GridViewRowItem's Item property gets cleared, and GridViewRow's DataContext is set to null. RadGridView does not differentiate DataTemplates from each other - the same internal logic is executed with both simple Binding and Multibinding. I guess that this is some framework peculiarity, related to handling Multibinding. Have you observed any performance degradation that might be related to this?

Regards,
Ivan Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Pete
Top achievements
Rank 1
answered on 12 Nov 2013, 04:46 PM
Well this behaviour was highlighted whilst trying to track down some performance issues and I posted the above whilst still suspicious about it. After further investigation, no, I don't believe this is degrading the performance at all. I have also seen it occur with a single binding so like you say, a framework peculiarity.

Thanks for replying and explaining the behaviour :)
Tags
GridView
Asked by
Pete
Top achievements
Rank 1
Answers by
Pete
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or