Gridview selected row - change cell color on action

3 posts, 1 answers
  1. Fredrik
    Fredrik avatar
    58 posts
    Member since:
    Mar 2013

    Posted 09 Oct 2013 Link to this post

    Hello!
    I have a gridview where i can select a row and click a button to start an action.
    I want to indicate which row that has a been executed, with a change in the color background on a given cell in the row selected.
    I have tried the following and it works, but the color disapears when you scroll and the row comes out of range.

    GridView.CurrentCell.ParentRow.Cells.Where(x => x.Column.Header.Equals("ID")).FirstOrDefault().Background = (SolidColorBrush)Background;

    please help
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 09 Oct 2013 Link to this post

    Hello,

    Please check our online documentation for more information on the problem you have encountered. 

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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 >>
  3. DevCraft banner
  4. Fredrik
    Fredrik avatar
    58 posts
    Member since:
    Mar 2013

    Posted 09 Oct 2013 Link to this post

    Thanks, works fine with using styleselector insted.

    my solution
    public class FakturaKidStyle : StyleSelector
        {
            public override Style SelectStyle(object item, DependencyObject container)
            {
                if (item is db_Transaksjon)
                {
                    db_Transaksjon trans = item as db_Transaksjon;
                    if (trans.p_Faktura != null)
                    {
                        var style = new Style();
                        style.TargetType = typeof(GridViewCell);
                        style.Setters.Add(new Setter() { Property = GridViewCell.BackgroundProperty, Value = cStyleAccessor.Brush_Fakturering()});
                        return style;
                    }
                    else
                    {
                        return (Style)Application.Current.Resources["GridViewCellStyle"]; 
                      
                    }
      
                }
                return null;
            }
      
        }
      
      
    <Grid.Resources>
    <my2:FakturaKidStyle x:Key="KidStyle">
                                  
    </my2:FakturaKidStyle>
    </Grid.Resources>
      
    <gridview:GridViewDataColumn DataMemberBinding="{Binding n_Bbs.p_Kid}" Header="{Binding LocalizedStrings.view_ukjentkid_kid, Source={StaticResource LocalizedStrings}}" CellStyleSelector="{StaticResource KidStyle}"
Back to Top