wpf style converter : "Convert" called by every datagrid column using it

Posted by Sonic Soul on Stack Overflow See other posts from Stack Overflow or by Sonic Soul
Published on 2010-06-17T18:47:10Z Indexed on 2010/06/17 19:43 UTC
Read the original article Hit count: 267

Filed under:
|

I created a converter, and assigned it to a style.

than i assigned that style, to the columns i want affected.

as rows are added, and while stepping through debugger, i noticed that the converter convert method gets called 1 time per column (each time it is used).

is there a way to optimize it better, so that it gets called only once and all columns using it get the same value?

 <Style x:Key="ConditionalColorStyle" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource CellStyle}">
        <Setter Property="Foreground">
            <Setter.Value>
                <Binding>
                    <Binding.Converter>
                        <local:ConditionalColorConverter />
                    </Binding.Converter>
                </Binding>
            </Setter.Value>
        </Setter>
    </Style>

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpfdatagrid