This is a migrated thread and some comments may be shown as answers.

Grid ist after added new item empty

1 Answer 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Reinhard
Top achievements
Rank 2
Reinhard asked on 17 Jun 2011, 09:48 AM
Hello.

I have a Test UC within a simple WPF-Grid an for test a Telerik RadGridView.When i added a new item, in the WPF-Grid, the Item is there, but in the Telerik Grid is after that empty. It shows new rows, but they are still empty (nothing is displayed.)

My Text xaml:
<UserControl x:Class="KfzOrtung6.Modells.UserControl1"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="498" d:DesignWidth="924"
             xmlns:my="clr-namespace:KfzOrtung6DataClasses.Modells;assembly=KfzOrtung6DataClasses"
             Loaded="UserControl_Loaded"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
     
    <UserControl.Resources>
        <CollectionViewSource x:Key="fahrzeugeViewSource" d:DesignSource="{d:DesignInstance my:Fahrzeuge, CreateList=True}" />
    </UserControl.Resources>
     
    <Grid DataContext="{StaticResource fahrzeugeViewSource}">
        <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="88" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="32,28,0,0" Name="fahrzeugeDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="654">
            <DataGrid.Columns>
                <DataGridTemplateColumn x:Name="ablaufsimkarteColumn" Header="Ablaufsimkarte" Width="SizeToHeader">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding Path=Ablaufsimkarte, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="aktivColumn" Binding="{Binding Path=Aktiv}" Header="Aktiv" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="bemerkungColumn" Binding="{Binding Path=Bemerkung}" Header="Bemerkung" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="iDColumn" Binding="{Binding Path=ID}" Header="ID" Width="SizeToHeader" />
                <DataGridTextColumn x:Name="kennzeichenColumn" Binding="{Binding Path=Kennzeichen}" Header="Kennzeichen" Width="SizeToHeader" />
                <DataGridTemplateColumn x:Name="nameColumn" Header="Name" Width="SizeToHeader">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox>
                                <ComboBoxItem Content="{Binding Path=Name}" />
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="rufnummerColumn" Binding="{Binding Path=Rufnummer}" Header="Rufnummer" Width="SizeToHeader" />
            </DataGrid.Columns>
        </DataGrid>
 
        <telerik:RadGridView x:Name="mygrid" Margin="32,136,0,35"
                             ItemsSource="{Binding}" HorizontalAlignment="Left" Width="654">
             
        </telerik:RadGridView>
         
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="795,162,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
    </Grid>
</UserControl>

My cs:
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using KfzOrtung6DataClasses.Modells;
 
namespace KfzOrtung6.Modells
{
    /// <summary>
    /// Interaktionslogik für UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
 
        KfzContext6 kt = new KfzContext6();
        public UserControl1()
        {
            InitializeComponent();
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            kt.MFahrzeuge.Load();
            var cc = kt.MFahrzeuge.Local;
 
            // Laden Sie Ihre Daten nicht zur Entwurfszeit.
            //if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            //{
            //  //Laden Sie hier Ihre Daten, und weisen Sie das Ergebnis der CollectionViewSource zu.
            CollectionViewSource myCollectionViewSource = (CollectionViewSource)this.Resources["fahrzeugeViewSource"];
                myCollectionViewSource.Source = cc;
            //}
        }
 
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Fahrzeuge fz = new Fahrzeuge
            {
                ID = Guid.NewGuid(),
                Name = "LKW Test 2",
                Kennzeichen = "Sad-Br-505",
                Ablaufsimkarte = new DateTime(2000, 1, 1),
                Rufnummer = "",
                Aktiv = 1
            };
            kt.MFahrzeuge.Add(fz);
            kt.SaveChanges();
 
            mygrid.Items.Refresh();
        }
    }
}


Please can you help?

Reinhard




1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 22 Jun 2011, 03:38 PM
Hello Reinhard,

I have tried to simulate the scenario described, but I was not able to reproduce the same behavior. May you take a look at the sample attached to verify whether there are any misunderstandings ? If so, may you provide the steps required so that I can reproduce your scenario ?
 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Reinhard
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or