开发者

Add Effect to some of the rows in a DataGrid

This is what I want: When user clicks a button, all rows that meets a criteria should have a Blur effect added

Problem: The only way I've found to do this is in the LoadingRow event. But in my case the row is already loaded when I want to apply the Blur Effect.

Question: How to iterate over rows so that I can apply the Blur effect. Or, even better, how can I bind a Effect to a row?

This is my code that only works when applying effect on start开发者_JAVA技巧up:

    private void dg_LoadingRow(object sender, DataGridRowEventArgs e)
    {
        if (true) // Logic for figuring out if a row should be blur'ed
            e.Row.Effect = new BlurEffect { Radius = 8 };
    }

Thanks for any help

Larsi


I found a solution to this:

Bind to the Effect property on the DataGridCellPresenter like this:

<sdk:DataGridCellsPresenter x:Name="CellsPresenter" Grid.Column="1" sdk:DataGridFrozenGrid.IsFrozen="True" Effect="{Binding ., Converter={StaticResource BlurConverter}}"/>

And the converter simply:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
    // Some logic...
    return new BlurEffect { Radius = 8 }; 
}

Lars Erik

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜