Silverlight: I have a datagrid that will only let me select the first row - i have no idea why
This is a wierd bug in my code and i have no idea what is causing it.
the code to build the datagrid seems to be good. It is copied from a datagrid that does function. The cause seems to be a control that this control is a child of.
EDIT: In my frustration i have removed any controls between the navigation framework and my control. My control uses a data context based off a generic class and i have verified that it works as intended through unit tests - besides a load method that sets the List property it is essentially empty. The load method works and returns a populated observable collection.
Everything loads and binds. The interaction works to hook up the grid and my detail form.
However the only cells that are selectable are those in the first row - however the other rows do highlight when you hover over them. They just do not respond to click events.
the big question is: Is anyone aware of any conditions (ie nesting of controls) that can cause this behavior? For isntance i know that using accordion controls and scrollViewers in conjunction has all kinds of nasty side effects.
EDIT: I tried substituting the control that works with this one (they inherit off the same base object so they are compatible. When i do this i get the same broken behaviour. this means that there is something wrong with the viewmodel ... or more likley the binding (but data is appearing :/) ...
the code for the datagrid:
<sdk:DataGrid
AutoGenerateColumns="False"
x:Name="dgBankCodes"
ItemsSource="{Binding List}"
IsReadOnly="True"
SelectionMode="Single" >
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding Code}" CanUserSort="True" Header="Bank Code" IsReadOnly="True"/>
<sdk:DataGridTextColumn Binding="{Binding Name}" CanUserSort="True" Header="Name" IsReadOnly="True"/>
<sdk:DataGridTextColumn Binding="{Binding SortCode}" CanUserSort="True" Header="Sort Code" IsReadOnly="True"/>
<sdk:DataGridTextColumn Binding="{Binding AccountNumber}" CanUserSort="True" Header="Act No" IsReadOnly="True"/>
<sdk:DataGridTextColumn Binding="{Binding Description}" CanUserSort="True" Header="Description" IsReadOnly="True"/>
<sdk:DataGridTextColumn Binding="{Binding IBAN}" Header="IBAN" IsReadOnly="True"/>
<sdk:DataGridTextColumn Binding="{Binding BIC}" CanUserSort="True" Header="BIC" IsReadOnly="True"/>
&开发者_StackOverflow中文版lt;/sdk:DataGrid.Columns>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectObjectCommand}"
CommandParameter="{Binding SelectedItem, ElementName=dgBankCodes}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</sdk:DataGrid>
This happens when you overwrite the Equals method for your objects class. Make sure each object is unique in your overridden Equals method
精彩评论