Not necessarily a bug, but a feature so basic it should be a bug:
DataGrid has no public refresh/update method so if you add items to a List that is being used as the ItemsSource, the DataGrid will not display the new items until you attempt to sort a column or point the ItemsSource at some other object (like null) then
back to the List that you just added to.
Not necessarily a bug, but a feature so basic it should be a bug:
DataGrid has no public refresh/update method so if you add items to a List that is being used as the ItemsSource, the DataGrid will not display the new items until you attempt to sort a column or point the ItemsSource at some other object (like null) then
back to the List that you just added to.
Hi, You can use ObservableCollection<DataObject> instead of List<DataObject> to hold your data. Then you should see the DataGrid or ListBox reflect that change automatically when you add item to the list or delete it from the list.
Sally Xu
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
3) If I have many columns in the DataGrid, when I scroll to right to see all the columns, sometimes the data row are broken in the middle.
i got the same problem here. i scroll right then it crashed. just size each column that will be solved. seems like a bug, the cell just can't re-size itself when scrolling............
YogevC
Member
14 Points
4 Posts
Re: DataGrid UI Bugs
Jun 29, 2008 03:48 PM | LINK
I have found a fix
[url]http://silverlight.net/forums/p/19436/66304.aspx#66304[/url]
jzabroski
Member
70 Points
53 Posts
Re: DataGrid UI Bugs
Jul 01, 2008 07:48 PM | LINK
Sorting is in fact broken in SL2B2, resulting in fatal crashes when you try to sort a column that had a binding failure.
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
dataGrid5.ItemsSource = Person.GetSamplePersonList();
}
}
public class Person
{
public Int32 Person_pk { get; set; }
public String FirstName { get; set; }
public String LastName { get; set; }
//commented out to simulate binding failure
//public String Address { get; set; }
public Person()
{
}
public static List<Person> GetSamplePersonList()
{
return new List<Person> {
new Person {Person_pk = 0, FirstName = "A.", LastName = "Zero"},
new Person {Person_pk = 1, FirstName = "B.", LastName = "One"},
new Person {Person_pk = 2, FirstName = "C.", LastName = "Two"},
new Person {Person_pk = 3, FirstName = "D.", LastName = "Three"}
};
}
}
<UserControl x:Class="Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data">
<StackPanel x:Name="LayoutRoot">
<TextBlock Text="DataGrid Demonstration"
Margin="0,20,10,20"
FontFamily="Verdana" FontSize="18" FontWeight="Bold"
Foreground="#FF5C9AC9" />
<Rectangle Fill="AliceBlue" HorizontalAlignment="Stretch" Height="1"/>
<TextBlock Text="DataGrid with template column:"/>
<data:DataGrid x:Name="dataGrid5"
Height="120"
Margin="0,5,0,10" HorizontalAlignment="Left"
AutoGenerateColumns="False">
<data:DataGrid.Columns>
<data:DataGridTemplateColumn>
<data:DataGridTemplateColumn.Header>
<TextBlock Text="Name"/>
</data:DataGridTemplateColumn.Header>
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Padding="5,0,5,0"
Text="{Binding FirstName}"/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
<data:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Padding="5,0,5,0"
Text="{Binding FirstName}"/>
<TextBox Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</data:DataGridTemplateColumn.CellEditingTemplate>
</data:DataGridTemplateColumn>
<!-- databinding to a column whose displaymemberbinding doesn't exist causes entire silverlight app to fail -->
<data:DataGridTextColumn Header="Address"
Width="300"
DisplayMemberBinding="{Binding Address}" />
</data:DataGrid.Columns>
</data:DataGrid>
</StackPanel>
</UserControl>
jzabroski
Member
70 Points
53 Posts
Re: Re: DataGrid UI Bugs
Jul 01, 2008 08:57 PM | LINK
Also, another bug in DataGrid:
Adding a DataGridTemplateColumn without a body is undefined, and fatally crashes the application:
In the above data grid code snippet, add:
<DataGridTemplateColumn/>
to the columns collection.
computeraddict
Member
2 Points
1 Post
Re: Re: DataGrid UI Bugs
Jul 01, 2008 11:25 PM | LINK
Not necessarily a bug, but a feature so basic it should be a bug:
DataGrid has no public refresh/update method so if you add items to a List that is being used as the ItemsSource, the DataGrid will not display the new items until you attempt to sort a column or point the ItemsSource at some other object (like null) then back to the List that you just added to.
sladapter
All-Star
43609 Points
7910 Posts
Re: Re: DataGrid UI Bugs
Jul 02, 2008 12:41 AM | LINK
Hi, You can use ObservableCollection<DataObject> instead of List<DataObject> to hold your data. Then you should see the DataGrid or ListBox reflect that change automatically when you add item to the list or delete it from the list.
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
heralight
Member
49 Points
30 Posts
Re: Re: DataGrid UI Bugs
Sep 01, 2008 03:23 PM | LINK
And to update your cell on every object update, your object must implement : INotifyPropertyChanged.
Please mark the posts as answers if they help and unmark if they don't.
http://www.hera.cc
sladapter
All-Star
43609 Points
7910 Posts
Re: Re: DataGrid UI Bugs
Sep 17, 2008 02:48 PM | LINK
Another DataGrid bug found. See this thread: http://silverlight.net/forums/t/27465.aspx
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
oyanglulu
Member
2 Points
1 Post
Re: DataGrid Bugs
May 25, 2009 02:22 AM | LINK
i got the same problem here. i scroll right then it crashed. just size each column that will be solved. seems like a bug, the cell just can't re-size itself when scrolling............