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:
My cs:
Please can you help?
Reinhard
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"
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