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

First Row is initially selected if bound to DataView

2 Answers 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Benedikt asked on 29 Oct 2019, 01:38 PM

Hey guys,

 

I have following Usercontrol with a RadGridView.

<UserControl
    x:Class="ReklamationsManagement.ucReklamationsTabelle"
    xmlns:mat="clr-namespace:Telerik.Windows.Controls.MaterialControls;assembly=Telerik.Windows.Controls"
    xmlns:local="clr-namespace:ReklamationsManagement"
    DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext}"
    >
    <Grid>
        <Grid.Resources>
            <local:GridRowStyle x:Key="GridRowStyle">
                <local:GridRowStyle.ImWerkStyle>
                    <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
                        <Setter Property="Background" Value="#A5D6A7"/>
                        <Setter Property="MouseOverBackground" Value="#4CAF50"/>
                        <Setter Property="SelectedBackground" Value="#388E3C"/>
                    </Style>
                </local:GridRowStyle.ImWerkStyle>
                <local:GridRowStyle.RestStyle>
                    <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}"/>
                </local:GridRowStyle.RestStyle>
            </local:GridRowStyle>
            <local:GridRowAlternateStyle x:Key="GridRowAlternateStyle">
                <local:GridRowAlternateStyle.ImWerkAlternateStyle>
                    <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
                        <Setter Property="Background" Value="#83c6a7"/>
                        <Setter Property="MouseOverBackground" Value="#45aa6a"/>
                        <Setter Property="SelectedBackground" Value="#37935c"/>
                    </Style>
                </local:GridRowAlternateStyle.ImWerkAlternateStyle>
                <local:GridRowAlternateStyle.RestAlternateStyle>
                    <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
                        <Setter Property="Background" Value="#349FA8DA"/>
                    </Style>
                </local:GridRowAlternateStyle.RestAlternateStyle>
            </local:GridRowAlternateStyle>
        </Grid.Resources>
        <telerik:RadGridView
            Grid.Column="1"
            x:Name="RadGridViewReklamationen"
            AutoGenerateColumns="False"
            GroupRenderMode="Flat"
            ShowGroupPanel="False"
            FilteringMode="Popup"
            ShowSearchPanel="False"
            ValidatesOnDataErrors="InEditMode"
            EnableColumnVirtualization="False"
            LeftFrozenColumnCount="7"
            PreviewKeyDown="RadGridViewReklamationen_PreviewKeyDown"
            ItemsSource="{Binding clsReklamationsTabelleDaten.dvReklamationen}"
            RowStyleSelector="{StaticResource GridRowStyle}"
            AlternateRowStyleSelector="{StaticResource GridRowAlternateStyle}"
            AlternationCount="2"
            >
            <telerik:RadGridView.Resources>
                <local:BooleanToTextConverter x:Key="BooleanToTextConverter"/>
            </telerik:RadGridView.Resources>
            <telerik:RadGridView.ColumnGroups>
                <telerik:GridViewColumnGroup
                    Name="BA"
                    Header="BA"
                    />
                <telerik:GridViewColumnGroup
                    Name="Objekt"
                    Header="Objekt"
                    />
                <telerik:GridViewColumnGroup
                    Name="Zeitpunkte"
                    Header="Bearbeitungs-Zeitpunkte"
                    />
                <telerik:GridViewColumnGroup
                    Name="Personen"
                    Header="Personen"
                    />
                <telerik:GridViewColumnGroup
                    Name="Lieferart"
                    Header="Lieferart"
                    />
                <telerik:GridViewColumnGroup
                    Name="Foto"
                    Header="Foto"
                    />
                <telerik:GridViewColumnGroup
                    Name="Lieferanschrift"
                    Header="Lieferanschrift"
                    />
                <telerik:GridViewColumnGroup
                    Name="Ursache"
                    Header="Ursache + Montage"
                    />
                <telerik:GridViewColumnGroup
                    Name="Fehlercode"
                    Header="Fehlercode"
                    />
                <telerik:GridViewColumnGroup
                    Name="Problem"
                    Header="Problem"
                    />
                <telerik:GridViewColumnGroup
                    Name="Verteiler"
                    Header="Verteiler"
                    />
                <telerik:GridViewColumnGroup
                    Name="Kommunikation"
                    Header="Kommunikation"
                    />
            </telerik:RadGridView.ColumnGroups>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Gebiet}"
                    Header="Gebiet"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Jahr}"
                    Header="Jahr"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LfdNr}"
                    Header="LfdNr"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding TA}"
                    Header="TA"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Los}"
                    Header="Los"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Mappe}"
                    Header="Mappe"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding ProduktTyp}"
                    Header="Produkt-Typ"
                    IsReadOnly="True"
                    ColumnGroupName="BA"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Anschrift}"
                    Header="Anschrift"
                    IsReadOnly="True"
                    ColumnGroupName="Objekt"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding PLZ}"
                    Header="PLZ"
                    IsReadOnly="True"
                    ColumnGroupName="Objekt"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Ort}"
                    Header="Ort"
                    IsReadOnly="True"
                    ColumnGroupName="Objekt"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Straße}"
                    Header="Straße"
                    IsReadOnly="True"
                    ColumnGroupName="Objekt"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Feststelldatum, StringFormat=d}"
                    Header="Festgestellt Am"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Anlegedatum, StringFormat=d}"
                    Header="Angelegt Am"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding TKEingang, StringFormat=d}"
                    Header="TK Eingang"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding TKRückfragen, StringFormat=d}"
                    Header="TK Rückfragen"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AVEingang, StringFormat=d}"
                    Header="AV Eingang"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding ProjektiererEingang, StringFormat=d}"
                    Header="PR Eingang"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding ReklamationsBesprechung, StringFormat=d}"
                    Header="BS Datum"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding WerkEingang, StringFormat=d}"
                    Header="WK Eingang"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding MonEinteilung, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Montageeinteilung"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding MonEinteilung, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding MontageDatum, StringFormat=d}"
                    Header="Montage Datum"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding MontageWoche}"
                    Header="Montagewoche"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding MontageJahr}"
                    Header="Montagejahr"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding ErledigtDatum, StringFormat=d}"
                    Header="Erledigt Datum"
                    IsReadOnly="True"
                    ColumnGroupName="Zeitpunkte"
                    />
                <!--<telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FestgestelltVon}"
                    Header="Festgestellt Von"
                    IsReadOnly="True"
                    ColumnGroupName="Personen"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AngelegtVon}"
                    Header="Angelegt Von"
                    IsReadOnly="True"
                    ColumnGroupName="Personen"
                    />-->
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Bearbeiter}"
                    Header="Bearbeiter"
                    IsReadOnly="True"
                    ColumnGroupName="Personen"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Ladetag, StringFormat=d}"
                    Header="Ladetag"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferart"
                    />
                <!--<telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Lieferart}"
                    Header="Lieferart"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferart"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LieferartZeit}"
                    Header="Abholzeit"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferart"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LieferartBemerkung}"
                    Header="Bemerkung"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferart"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FotoNichtNötig, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Foto Nicht Benötigt"
                    IsReadOnly="True"
                    ColumnGroupName="Foto"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding FotoNichtNötig, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FotoDa, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Foto Vorhanden"
                    IsReadOnly="True"
                    ColumnGroupName="Foto"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding FotoDa, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FotoAngefordertAm, StringFormat=d}"
                    Header="Foto Angefordert Am"
                    IsReadOnly="True"
                    ColumnGroupName="Foto"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LieferanschriftAnschrift}"
                    Header="Lieferanschrift Anschrift"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferanschrift"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LieferanschriftStrasse}"
                    Header="Lieferanschrift Straße"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferanschrift"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LieferanschriftPLZ}"
                    Header="Lieferanschrift PLZ"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferanschrift"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding LieferanschriftOrt}"
                    Header="Lieferanschrift Ort"
                    IsReadOnly="True"
                    ColumnGroupName="Lieferanschrift"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Verursacher}"
                    Header="Verursacher"
                    IsReadOnly="True"
                    ColumnGroupName="Ursache"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Belastung, StringFormat=c2}"
                    Header="Belastung"
                    IsReadOnly="True"
                    ColumnGroupName="Ursache"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Montagevorgabezeit}"
                    Header="Montagevorgabezeit in h"
                    IsReadOnly="True"
                    ColumnGroupName="Ursache"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding ReklamationsArt}"
                    Header="ReklamationsArt"
                    IsReadOnly="True"
                    ColumnGroupName="Fehlercode"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FehlerBereich}"
                    Header="FehlerBereich"
                    IsReadOnly="True"
                    ColumnGroupName="Fehlercode"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FehlerBeschreibung}"
                    Header="FehlerBeschreibung"
                    IsReadOnly="True"
                    ColumnGroupName="Fehlercode"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding FehlerUrsache}"
                    Header="FehlerUrsache"
                    IsReadOnly="True"
                    ColumnGroupName="Fehlercode"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Situation}"
                    Header="Situation"
                    IsReadOnly="True"
                    ColumnGroupName="Problem"
                    MaxWidth="500"
                    TextWrapping="Wrap"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding Anweisung}"
                    Header="Anweisung"
                    IsReadOnly="True"
                    ColumnGroupName="Problem"
                    MaxWidth="500"
                    TextWrapping="Wrap"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerEndmontage, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Endmontage"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerEndmontage, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerMonteur, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Monteur"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerMonteur, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerSäge, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Säge"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerSäge, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerBAZ, Converter={StaticResource BooleanToTextConverter}}"
                    Header="BAZ"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerBAZ, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerMagazin, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Magazin"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerMagazin, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerKanban, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Kanban"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerKanban, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerBlech, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Blech"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerBlech, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerKleben, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Kleben"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerKleben, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerAlu, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Alu"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerAlu, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerFachberater, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Fachberater"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerFachberater, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerMontageAkte, Converter={StaticResource BooleanToTextConverter}}"
                    Header="MontageAkte"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerMontageAkte, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding VerteilerEinkauf, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Einkauf"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding VerteilerEinkauf, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding RücklieferungWerk, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Rücklieferung Werk"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding RücklieferungWerk, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding RücklieferungWerkAngekommen, Converter={StaticResource BooleanToTextConverter}}"
                    Header="Rücklieferung Angekommen"
                    IsReadOnly="True"
                    ColumnGroupName="Verteiler"
                    >
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox
                                IsChecked="{Binding RücklieferungWerkAngekommen, Mode=TwoWay}"
                                IsEnabled="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AnsprechpartnerAnrede}"
                    Header="Ansprechpartner Anrede"
                    IsReadOnly="True"
                    ColumnGroupName="Kommunikation"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AnsprechpartnerVorname}"
                    Header="Ansprechpartner Vorname"
                    IsReadOnly="True"
                    ColumnGroupName="Kommunikation"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AnsprechpartnerNachname}"
                    Header="Ansprechpartner Nachname"
                    IsReadOnly="True"
                    ColumnGroupName="Kommunikation"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AnsprechpartnerTelefon}"
                    Header="Ansprechpartner Telefon"
                    IsReadOnly="True"
                    ColumnGroupName="Kommunikation"
                    />
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding AnsprechpartnerEMail}"
                    Header="Ansprechpartner EMail"
                    IsReadOnly="True"
                    ColumnGroupName="Kommunikation"
                    />-->
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding GeplanteKommunikation, StringFormat=d}"
                    Header="GeplanteKommunikation"
                    IsReadOnly="True"
                    ColumnGroupName="Kommunikation"
                    />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</UserControl>

 

The Itemsource of it is a DataView with SQL-data.

I have now applied a RowStyleSelector and with this occured a problem: The first row is always not really selected, but highlighted. I added a picture of it.

If I click the row gets really selected and the Style gets applied. I don't seem to have this problem with Bindings to Observable Collections. But completely convert the Dataview to another Collection seems to be really time consuming.

If I set IsSynchronizedWithCurrentItem to false, it works, but I not really want to miss the Indicator.

This: grid.Loaded += new RoutedEventHandler((sender, e) => { (sender as RadGridView).CurrentItem = null; }); changes nothing.

Setting the SelectedItem to the first DataRowView initially also not works.

 

Has anyone any other ideas?

 

Greetings,

Benedikt

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 31 Oct 2019, 02:05 PM

Hello Benedikt,

This is the default behavior when using a collection view. To resolve it you can set the IsSynchronizedWithCurrentItem property of RadGridView to False, as you already found out. This solution is described in the First Row is Always Selected troubleshooting article.

If you want to preserve the synchronization with the current item, you can set the property initially to False, and on the first selection that happens in the gridview to set it back to True. For example:

<telerik:RadGridView IsSynchronizedWithCurrentItem="False" SelectionChanging="RadGridView_SelectionChanging"/>

private void RadGridView_SelectionChanging(object sender, SelectionChangingEventArgs e)
{
	var gridView = (RadGridView)sender;
	gridView.IsSynchronizedWithCurrentItem = true;
	gridView.SelectionChanging -= RadGridView_SelectionChanging;
}

Can you please try this and let me know if it helps?

As a side note, the first item is gray initially because this is the visual state of the selected row when the gridview control is not focused. Once, you focus the gridview, the row enters the selected-focused visual state and its background changes to a more colorful nuance. 

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
answered on 04 Nov 2019, 07:48 AM

Hey Martin,

your tip with the not focused row helped me. I now just set the mat:MaterialAssist.CheckedBrush in my RowStyles for the RowStyleSelector (<Setter Property="mat:MaterialAssist.CheckedBrush" Value="#37935c"/>) and everything works as a charme. 

Greetings

Benedikt

Tags
GridView
Asked by
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Benedikt
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or