Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hai
I am new to wpf. I want to create an user control unbound datagrid in wpf

I inherited a datagrid


XAML Code is

HTML
<datagrid x:class="MyGrid" xmlns:x="#unknown">
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:NewGrid"
             mc:Ignorable="d" 
             d:DesignHeight="180.397" d:DesignWidth="320.354" removed="{x:Null}" AutoGenerateColumns="False" ColumnHeaderHeight="25"  RowHeaderWidth="20" ClipboardCopyMode="IncludeHeader" SelectionMode="Single" SelectionUnit="Cell" EnableRowVirtualization="False" HeadersVisibility="None" CanUserAddRows="False" >
</datagrid>



In Code Window

VB
    Private Sub MyGrid_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        Me.Items.Add(Me.Items()) ' Used to add an empty row on start
    End Sub

Private Sub MyGrid_PreviewKeyDown(sender As Object, e As KeyEventArgs) Handles Me.PreviewKeyDown    
	If m_AddRow = True Then
		Me.Items.Add(Me.Items())
       End If

End Sub


My problem is

When I run this by adding a new grid it shows this error
'EditItem' is not allowed for this view.

Please help me , how to create editable unbound grid. I don't want data bound grid.
Posted
Updated 12-Jan-16 3:37am
v3
Comments
Richard Deeming 12-Jan-16 10:13am    
That code doesn't make any sense - you're adding the Items collection to itself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900