附加信息:此视图不允许使用元素“EditItem”
我的班级
public class MyData
{
public int id { get;set; }
public string Name { get; set; }
public string LastName { get; set; }
}
我的清单 List ListaStrukt = new List();
xaml代码
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid GotFocus="Grid_GotFocus">
<Grid.RowDefinitions>
<RowDefinition Height="184*"/>
<RowDefinition Height="135*"/>
</Grid.RowDefinitions>
<Button Name="ButtonEdit" Visibility="Hidden" Margin="274,32,0,105">Edit selected cell</Button>
<Button Name="NextRow" Margin="210,32,243,110" Click="NextRow_Click" Visibility="Hidden" >Previous</Button>
<Button Margin="0,32,396,110" Click="Button_Click" Visibility="Hidden">Find</Button>
<Label Name="Labeliffound" Margin="10,37,0,110" HorizontalAlignment="Left" Width="210"/>
<TextBox Name="TextBoxName" Margin="274,0,121,152" GotFocus="TextBoxName_GotFocus">Type here Name</TextBox>
<TextBox Name="TextBoxLastName" Margin="396,0,0,152" HorizontalAlignment="Left" Width="121" GotFocus="TextBoxTitle_GotFocus" >Type here last name</TextBox>
<Button Name="ButtonName" Margin="274,32,0,105" Click="ButtonName_Click">Add name and Last name</Button>
<TextBox Name="TexBoxSearch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" GotFocus="TexBoxSearch_GotFocus" TextChanged="TextBox_TextChanged" Margin="1,0,248,152" >Type here to search</TextBox>
<DataGrid x:Name="myDataGrid" DataGridCell.Selected="myDataGrid_GotFocus" ItemsSource="{Binding ListaStrukt}" CanUserAddRows="True" IsReadOnly="False" CanUserReorderColumns="True" CanUserSortColumns="True" Margin="0,79,0,0" Grid.RowSpan="2" KeyDown="myDataGrid_KeyDown_1" SelectionChanged="myDataGrid_SelectionChanged" LostFocus="myDataGrid_LostFocus" GotFocus="myDataGrid_GotFocus" Cursor="None">
<DataGrid.Columns>
<DataGridTextColumn Header=" Id" Width="30" Binding="{Binding id}" />
<DataGridTextColumn Header="Name" Width="60" Binding="{Binding Name, Mode=OneWay}"/>
<DataGridTextColumn Header="LastName" Width="90" Binding="{Binding LastName, Mode=OneWay}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
错误
无法获取本地或参数''的值,因为它在此指令指针处不可用,可能是因为它已经被优化掉了。 System.Windows.Controls.ItemCollection
无法获取本地或参数'item'的值,因为它在此指令指针处不可用,可能是因为它已被优化掉了。对象
我试图解决这个问题,但我读了很多帖子和答案,但仍然没有。
当我想双击DataGrid单元格时出现错误。我很感激你的帮助。