'EditItem' is not allowed for this view.

Apr 7, 2009 at 1:34 PM

Hi,

I am using wpf datagrid and I'm unable to edit data in it. When I double click a cell I get the error listed in the discussion name "'Edit item' is not allowed for this view".

.xaml =>
<Window x:Class="IPS.Instrumentarij.TipoviInstrumenataWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Tipovi instrumenata" Height="480" Width="640" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" Loaded="Window_Loaded">
    <Grid>
        <my:DataGrid Margin="12" x:Name="tipoviInstrumentaDataGrid" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" AutoGenerateColumns="False" >
            <my:DataGrid.Columns>
                <my:DataGridTextColumn x:Name="nameDataGridTextColumn" Header="Naziv" Width="100" Binding="{Binding Path=Name}" />
                <my:DataGridTextColumn x:Name="serijaDataGridTextColumn" Header="Serija" Width="100" Binding="{Binding Path=Serija}"/>
                <my:DataGridTextColumn x:Name="artNoDataGridTextColumn" Header="Art.No." Width="100" Binding="{Binding Path=ArtNo}"/>
                <my:DataGridTextColumn x:Name="descriptionDataGridTextColumn" Header="Opis" Width="100" Binding="{Binding Path=Description}"/>
                <my:DataGridComboBoxColumn x:Name="proizvodjacDataGridComboBoxColumn" Header="Proizvođač" Width="100*" SelectedValueBinding="{Binding Path=ProizvodjacId}" ItemsSource="{Binding}" SelectedValuePath="Id" DisplayMemberPath="Name"/>
            </my:DataGrid.Columns>
        </my:DataGrid>
    </Grid>
</Window>

Code behind

    public partial class TipoviInstrumenataWindow : Window
    {
        private TipoviInstrumenataController _controller;

        public TipoviInstrumenataWindow()
        {
            InitializeComponent();
            _controller = new TipoviInstrumenataController();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.proizvodjacDataGridComboBoxColumn.ItemsSource = _controller.GetProizvodjaci();
            this.tipoviInstrumentaDataGrid.DataContext = _controller.GetTipoviInstrumenata();
        }
    }

_controller.GetTipoviInstrumenata returns IQueryable<TipInstrumenta> where TipInstrumenta is a domain object (read from the database using LINQ to SQL).

Can someone help me on this one? Putting TwoWay mode didn't help, neither did explicitely specifying that DataGrid is not read only.

Coordinator
Apr 7, 2009 at 8:41 PM
Hi Milivojm, Can you attach the full application?

Apr 8, 2009 at 7:13 AM
As I don't see attach function here, I've uploaded it on another server. Here is the link:

http://jumbo.iskon.hr/dl/142m0mc5iedjt383/

Thank you for your help.