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

Gridview selected row - change cell color on action

2 Answers 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 2
Fredrik asked on 09 Oct 2013, 06:38 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 09 Oct 2013, 10:25 AM
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 >>
0
Fredrik
Top achievements
Rank 2
answered on 09 Oct 2013, 12:28 PM
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}"
Tags
GridView
Asked by
Fredrik
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Fredrik
Top achievements
Rank 2
Share this question
or