Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

When clicking on datagrid row it throws me exception - WPF C#

$
0
0

Whenever I try to double click my datagrid row to edit it, I throws me a few exceptions which doesn't say anything to me. Hovever if I set the whole datagrid to IsReadOnly to true, I want have the problem, but I need the second and third columns editable.

XAML

<DataGrid x:Name="clientList" HorizontalAlignment="Left" Height="225" Margin="11,126,0,0" VerticalAlignment="Top" Width="349" IsSynchronizedWithCurrentItem="False" AutoGenerateColumns="False" HorizontalGridLinesBrush="#FFB9B9B9" VerticalGridLinesBrush="#FF8B8B8B" GridLinesVisibility="Horizontal" CellStyle="{StaticResource Body_Content_DataGrid_Centering}"><DataGrid.Resources><LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" StartPoint="0,0" EndPoint="0,1" ><GradientStop Color="#66240000" Offset="0"/><GradientStop Color="#CC240000" Offset="0.65"/></LinearGradientBrush></DataGrid.Resources><DataGrid.Columns><DataGridTextColumn Width="30" Header="Id" IsReadOnly="True" Binding="{Binding Id}"/><DataGridTextColumn Width="100" Header="Company" IsReadOnly="False" Binding="{Binding Company}"/><DataGridTextColumn Width="130" Header="Name, Surname" IsReadOnly="False" Binding="{Binding Name}"/><DataGridTemplateColumn Header="Actions" CellTemplate="{StaticResource myTemplate}"/></DataGrid.Columns></DataGrid>

C#

clientList.Items.Add(new DataClients { Id = 1, Company = "My Company", Name = "Jane Roe"});

Exceptions

Exception:Thrown: "'EditItem' is not allowed for this view."(System.InvalidOperationException)

Exception:Thrown: "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0." (System.FormatException)

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>