Page view counter
Silverlight 2 DataGrid December 2008 Release Subscribe to this thread
Last post 07-03-2009 11:10 AM by ossc_webapp. 65 replies.
Sort Posts:
12-19-2008 2:51 PM
Silverlight 2 DataGrid December 2008 Release

Silverlight 2 DataGrid December 2008 Release

We have just uploaded a new version of the DataGrid that includes a number of bug fixes and a few behavioral breaking changes from the version that shipped with Silverlight 2.  Please take the time to read through and understand all of the changes before you decide to upgrade your DataGrid.  Following this list of changes is a set of instructions on how to start using the new version.

 

Breaking Changes

An application that uses the DataGrid will still compile but will no longer work as expected if it was dependent on any of the following behaviors.

1.       FrozenColumnCount now takes hidden columns into account.  Previously, only the first columns with Visibility set to Visible were included in the range of frozen columns.  A column with Visibility set to Collapsed can now be considered frozen even though it isn’t visible.  This is to ensure that a column’s DisplayIndex corresponds with the DataGrid’s FrozenColumnCount (i.e. if FrozenColumnCount == 3, columns with DisplayIndex < 3 are considered frozen).

2.       The DataGrid’s current cell is now kept in sync with an ICollectionView’s notion of currency.  Moving the current position or changing the current item of an ICollectionView will now move the current cell and selected item of a DataGrid, and vice versa.  For this to work, the DataGrid’s ItemsSource must be set to a collection that fully implements ICollectionView.

3.       A developer can now programmatically reorder a non-frozen column to the frozen column range (and vice versa) by changing a column’s DisplayIndex.  The DataGrid used to throw an exception in these cases.  An end-user, however, is still unable to do this through the UI by dragging column headers.

 

Bugs Fixed

The following is a list of bugs fixed in the DataGrid since the version released with Silverlight 2.  If any application had a workaround for these bugs, the workaround is no longer necessary and should be removed.  Its inclusion may cause undesired behavior.

1.       Horizontal Gridlines do not show in FillerColumn

2.       DragIndicator does not show during reorder when DataGrid is placed inside StackPanel

3.       DragIndicatorStyle only exists on the DataGrid level, should also exist at the column level

4.       DataGrid doesn't support a disabled state in the main template
By default, the DataGrid is now grayed out when IsEnabled == false, and includes a new visual state.

5.       EndEdit is called twice
      Any application accounting for IEditableObject.EndEdit accidentally being called twice by the DataGrid will need to be updated.
6.       Able to leave edited DataGrid without ever triggering EndEdit

7.    Changing ItemsSource while in Editing Mode causes Exception to be thrown

8.       Row containing focus disappears after sort or ItemsSource change
Any application working around the “disappearing row” issue by manipulating focus within the DataGrid will no longer need to do so, and should be updated.

9.       ColumnHeader button pressed visualization should match the new Button pressed visualization

10.   SL Designer hits a NullReferenceException while adding an empty HeaderStyle

11.   Cells out of view do not always show up when a resize of the DataGrid forces them in view

12.   AutoSizedRows keep growing even when the rows are recycled

13.   Scrollbar incorrect when ItemsSource changed and DataGrid is on a background Tab

14.   Incorrect VerticalScrollbar when setting ItemsSource on DataGrid inside a Popup

15.   HorizontalContentAlignment does not have any effect on the DataGridColumnHeader

16.   Resizing columns to smaller than column header content removes separator

17.   SelectedItem is not updated at the time when the CurrentCellChanged event is raised

      Any application accounting for the fact that Selection was out of sync at the time the CurrentCellChanged event was raised will need to be updated.  Now the DataGrid will not raise either of the SelectionChanged or CurrentCellChanged events until both selection and currency have been updated.

18.   Sorting or Resetting a CollectionView causes incorrect RemovedItems in SelectionChanged event

19.   ScrollColumnIntoView does not align correctly if there are frozen columns

20.   Reordering a column should only show DragIndicator for valid reorder positions

      The DataGrid will now clip the ColumnHeader’s DragIndicator so that it doesn’t show up when dragging a frozen column over a non-frozen column, and vice versa.

21.   Adding or removing columns within the frozen column range should not throw exception

22.   FrozenColumnCount and the Column’s IsFrozen is getting out of sync when it isn’t visible

23.   Exception thrown when sorting a DataGrid that has a list of nullable ints as its ItemsSource

24.   CellStyle Background property doesn’t work

      Previously, setting the Background property inside of CellStyle had no effect.  Applications with unique CellStyles should ensure that the desired background color is applied.

25.   CellStyle is not applied to Filler Column

26.   Setting a DataGrid style that overwrites the template after the original template has been loaded causes an Argument exception

27.   Cannot hold editing mode when using a DatePicker or ComboBox in editing template

      There was a bug that prevented any editing control that uses a Popup to work correctly in the DataGrid.  As soon as the Popup opened, the DataGrid would lose focus and automatically CommitEdit.  It now tracks focus within a child Popup in order to support DatePicker, ComboBox and any other editing control that opens a Popup.

28.   Double-click required on external Buttons when in editing mode

      A single click on Buttons (or any other control that handles MouseLeftButtonDown) outside of the DataGrid will now register correctly.  Previously, if the user was in editing mode, the first click would CommitEdit and the second click would register on the Button.

29.   Sorting or resetting the ItemsSource does not raise UnloadingRow events

30.  Contents of columns out of view do not always show up when the DataGrid is resized such that they are brought into view

 

Installation Instructions

Visit the Silverlight 2 DataGrid December 2008 Release download page and read the installation instructions carefully.  In order to successfully use the new DataGrid you must do the following.

1.       Close all instances of Microsoft Visual Studio.2.       Delete all cached toolbox items by removing all files beginning with "toolbox" from %LocalAppData%\Microsoft\VisualStudio\9.0.
  • On Microsoft Windows XP, %LocalAppData% is Documents and Settings\UserName\Local Settings\Application Data.
  • On Microsoft Windows Vista, %LocalAppData% is Users\UserName\AppData\Local.
3.    Replace the following assemblies with the ones in this package:
  • %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.Windows.Controls.Data.dll
  • %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.Windows.Controls.Data.Design.dll

4.       For any existing projects, delete the reference to System.Windows.Controls.Data.dll and then re-add the reference.

 

 

Happy Holidays from the Silverlight DataGrid Team!

 

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
12-20-2008 3:54 AM
Re: Silverlight 2 DataGrid December 2008 Release

Does this release also enable mouseover states for single cells (change foreground color for labels inside cells on mouseover).

edit: good job btw Smile

Regards,
Nathan Brouwer

http://www.nathanbrouwer.nl

party42

Loading...
Joined on 04-17-2006
Utrecht
Posts 318
12-20-2008 7:20 PM
Re: Silverlight 2 DataGrid December 2008 Release

 "15.   HorizontalContentAlignment does not have any effect on the DataGridColumnHeader"

 

YES! I have been waiting for that one, should fix alot of the dynamic resizing now...  Now I hafta remove my DataView I made to replace DataGrid.  Thanks alot for the update, it was much needed here!

xsirxx

Loading...
Joined on 04-28-2008
Posts 33
12-23-2008 3:12 PM
Re: Silverlight 2 DataGrid December 2008 Release

The MouseOver, Selected, and Current states on the DataGridCell should be working.  Please let us know if you find otherwise.  Previously there was a bug where the cell's Background could not be styled, but that was fixed in our mini release.

Yifung Lin [MSFT]

yifung

Loading...
Joined on 03-25-2008
Redmond, WA
Posts 391
12-27-2008 9:57 AM
Re: Silverlight 2 DataGrid December 2008 Release
Thanks much for the post. But I guess how does the end user gets the new grid? If I have a app that uses the new grid, how does the above mentioned dlls get to user's machine?
rtalwalkar

Loading...
Joined on 10-25-2008
Posts 12
12-29-2008 1:24 PM
Re: Silverlight 2 DataGrid December 2008 Release

The short answer is it'll happen automatically.

The DataGrid is not part of the Silverlight core package.  You got the original dll from the SDK and compiled your app with it.  Everything in your app that's not part of the core assemblies is packaged into a xap (including the DataGrid dll) file.  That xap file is downloaded by any user viewing your Silverlight page.  As a result, as long as you build your app with the new DataGrid dll's, your customers will be using the new version as well.

Yifung Lin [MSFT]

yifung

Loading...
Joined on 03-25-2008
Redmond, WA
Posts 391
12-30-2008 8:52 AM
Re: Silverlight 2 DataGrid December 2008 Release
Ok. Thanks much.
rtalwalkar

Loading...
Joined on 10-25-2008
Posts 12
12-31-2008 12:17 PM
Re: Silverlight 2 DataGrid December 2008 Release

Great thanks! Any idea when there will be datagrid which will support paging?

WilcoBl8

Loading...
Joined on 10-16-2008
Posts 3
12-31-2008 1:10 PM
Re: Silverlight 2 DataGrid December 2008 Release

There isn't a concrete date yet but pieces like a pageable data source are being worked on.  It is a scenario we will enable in the future

Yifung Lin [MSFT]

yifung

Loading...
Joined on 03-25-2008
Redmond, WA
Posts 391
01-01-2009 2:23 AM
Re: Silverlight 2 DataGrid December 2008 Release
Let the force be with you and the Silver Light development team. I was waiting for this since the RTW. Now I can have at-least few good night sleep. Wish you and all of us a very happy 2009 with SL2-SL2.5-SL3.......
a2005

Loading...
Joined on 09-04-2008
India
Posts 34
01-05-2009 11:54 AM
Re: Silverlight 2 DataGrid December 2008 Release

Does this release resolve these issues?

1. By default DataGrid's SelectedIndex property is set to "0". While trying to set it to SelectedIndex = -1, doesn't work.  No error, but basically it will be ignored and after databinding, SelectedIndex  property is still "0".

2. DataGrid's "SelectionChanged" event fires twice for some reason.

SLGuy

Loading...
Joined on 12-19-2008
Posts 5
01-05-2009 5:03 PM
Re: Silverlight 2 DataGrid December 2008 Release

1. Unfortunately this issue is not resolved with this update.  You could work around it by listening to the SelectionChanged event and setting the SelectedIndex to -1 inside the handler the first time it gets called after setting the ItemsSource.

2.  Under what circumstances was the SelectionChanged event being fired twice?  Also, was it being raised with the same args?  Using the new version, I can confirm that the event is only raised once when selection is changed under normal conditions, but maybe there's some edge scenario I'm not seeing.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
01-05-2009 11:38 PM
Re: Silverlight 2 DataGrid December 2008 Release

 Congratulations on the release, Brian! Downloading the bits now... For some reason, this just hit my newsreader now.

Jeff Wilcox [MSFT]
Software Development Engineer
Silverlight
http://www.jeff.wilcox.name/blog/

This posting is provided "AS IS" with no warranties, and confers no rights.

JWilcox

Loading...
Joined on 07-14-2005
Seattle
Posts 175
01-06-2009 2:07 AM
Re: Silverlight 2 DataGrid December 2008 Release

yifung:

The MouseOver, Selected, and Current states on the DataGridCell should be working.  Please let us know if you find otherwise.  Previously there was a bug where the cell's Background could not be styled, but that was fixed in our mini release.



could you please elaborate on howto do this. we have a datagrid with hyperlinks. somehow, changing the background is not a problem (on mouseover) but changing the links (or labels) foreground color doesn't quite work.

Regards,
Nathan Brouwer

http://www.nathanbrouwer.nl

party42

Loading...
Joined on 04-17-2006
Utrecht
Posts 318
01-06-2009 11:14 AM
Re: Silverlight 2 DataGrid December 2008 Release

Thanks Brian!  Here is the source code.  For some reason, everytime Search button is clicked, the dg_SelectionChanged fires twice.

XAML Page:

<UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="SQLData.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sd="clr-namespace:SQLData" 
    Width="700" Height="300">
    <Grid x:Name="LayoutRoot" Background="White" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="10" /><!--0 Margin-->
            <RowDefinition Height="50" /><!--1 Prompts-->
            <RowDefinition Height="*" /><!--2 DataGrid-->
            <RowDefinition Height="30" /><!--2 Navigation Buttons-->
            <RowDefinition Height="10" /><!--3 Margin-->
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="10" /><!--0 Margin-->
            <ColumnDefinition Width="*" /><!--1 Controls-->
            <ColumnDefinition Width="10" /><!--2 Margin-->
        </Grid.ColumnDefinitions>

        <Border BorderBrush="Black" BorderThickness="2" Grid.Row="1" Grid.Column="1"/>

        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
            <TextBlock Text="Last name to search for: " VerticalAlignment="Bottom" 
                FontSize="18" Margin="15,0,0,0" />
            <TextBox x:Name="LastName" Width="250" Height="30" Margin="2,0,0,4" 
                VerticalAlignment="Bottom"/>
            <Button x:Name="Search" Width="75" Height="30" 
                Margin="20,0,0,4" Content="Search"
                VerticalAlignment="Bottom"  Background="Blue" FontWeight="Bold" FontSize="14" />
        </StackPanel>

        <data:DataGrid x:Name="dg" Grid.Row="2" Grid.Column="1" CanUserSortColumns="True" SelectionChanged="dg_SelectionChanged" IsReadOnly="True"></data:DataGrid>
        
        <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" x:Name="spNavigation" Visibility="Collapsed">
            <Button Width="60" Height="20" Margin="15,0,0,0" x:Name="btnNext" Content="Next"/>
            <TextBlock Width="60" Height="20" Margin="20,0,0,0" x:Name="lblPageNo" Text="PageNo"/>
            <Button Width="60" Height="20" Margin="20,0,0,0" x:Name="btnPrevious" Content="Previous"/>
        </StackPanel> 
        <sd:Detail x:Name="DetailsView" Grid.RowSpan="5" Grid.ColumnSpan="3" Visibility="Collapsed"></sd:Detail>
    </Grid>
</UserControl>
 

------------------------------------

Code Behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SQLData
{
    public partial class Page : UserControl

    {
        public int TotalRows { get; set; }
        public int PageSize { get; set; }
        int TotalPages = 0;
        int PageNo = 1;
        bool b;
        ServiceReference1.Service1Client webService = new SQLData.ServiceReference1.Service1Client();

        public Page()
        {
            InitializeComponent();
            PageSize = 10;
            //Loaded += new RoutedEventHandler(Page_Loaded);

            Search.Click += new RoutedEventHandler(Search_Click);
            btnNext.Click += new RoutedEventHandler(btnNext_Click);
            btnPrevious.Click += new RoutedEventHandler(btnPrevious_Click);
            webService.GetTotalRecordsCompleted += new EventHandler(webService_GetTotalRecordsCompleted);
            webService.GetCustomersByLastNameCompleted += new EventHandler(webService_GetCustomersByLastNameCompleted);
        }

        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //Search.Click += new RoutedEventHandler(Search_Click);
            //btnNext.Click += new RoutedEventHandler(btnNext_Click);
            //btnPrevious.Click += new RoutedEventHandler(btnPrevious_Click);

            //webService.GetTotalRecordsCompleted += new EventHandler<SQLData.ServiceReference1.GetTotalRecordsCompletedEventArgs>(webService_GetTotalRecordsCompleted);
            //webService.GetCustomersByLastNameCompleted += new EventHandler<SQLData.ServiceReference1.GetCustomersByLastNameCompletedEventArgs>(webService_GetCustomersByLastNameCompleted);
        }

        void Search_Click(object sender, RoutedEventArgs e)
        {
            TotalRows = 0;
            PageNo = 1;
            TotalPages = 0;
             
            webService.GetTotalRecordsAsync(LastName.Text);
            webService.GetCustomersByLastNameAsync(LastName.Text, PageNo, PageSize);
            spNavigation.Visibility = Visibility.Visible;
            b = true;
        }

        void webService_GetCustomersByLastNameCompleted(object sender, SQLData.ServiceReference1.GetCustomersByLastNameCompletedEventArgs e)
        {
            if (TotalPages == 0)
            {
                btnNext.IsEnabled = false;
                btnPrevious.IsEnabled = false;
                PageNo = 0;
                lblPageNo.Text = PageNo.ToString() + " of " + TotalPages.ToString();
                dg.ItemsSource =null;
            }
            else
            {
                if (PageNo == 1)
                {
                    btnNext.IsEnabled = true;
                    btnPrevious.IsEnabled = false;
                }
                else if (PageNo == TotalPages)
                {
                    btnNext.IsEnabled = false ;
                    btnPrevious.IsEnabled = true;
                }
                dg.ItemsSource = e.Result;
                lblPageNo.Text = PageNo.ToString() + " of " + TotalPages.ToString();
            }
        }

        void webService_GetTotalRecordsCompleted(object sender, SQLData.ServiceReference1.GetTotalRecordsCompletedEventArgs e)
        {
            TotalRows = e.Result;
            if (TotalRows != 0)
            {
                TotalPages = TotalRows / PageSize + 1;
            }
            else
            {
                TotalPages = 0;
            }
        }

        void btnNext_Click(object sender, RoutedEventArgs e)
        {
            PageNo = PageNo + 1;
            webService.GetCustomersByLastNameAsync(LastName.Text, PageNo, PageSize);
            if (PageNo == TotalPages)
            {
                btnNext.IsEnabled = false;
                btnPrevious.IsEnabled = true;
            }
        }

        void btnPrevious_Click(object sender, RoutedEventArgs e)
        {
            PageNo = PageNo - 1;
            webService.GetCustomersByLastNameAsync(LastName.Text, PageNo, PageSize);
        }

        private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid grid = sender as DataGrid;
            if (grid.SelectedItem == null)
            {
                b = true;
            }
            else
            {
                if (b)
                {
                    DetailsView.Visibility = Visibility.Collapsed;
                    b = false;
                }
                else
                {
                    DetailsView.Visibility = Visibility.Visible;
                }
            }
        }
    }
}
 
SLGuy

Loading...
Joined on 12-19-2008
Posts 5
01-06-2009 3:45 PM
Re: Silverlight 2 DataGrid December 2008 Release

So it looks like when the Search button is Pressed, the DataGrid's ItemsSource is changed and that's when you're experiencing multiple SelectionChanged events.  I'm assuming the first event says that selection has been removed, and the second event says that the first item has been selected.

I believe that the event will only be raised once under these conditions with the new release, so it should be fixed.  I don't have the correct bits installed to verify this right now, but I'll try to confirm it when I get a chance.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
01-07-2009 10:59 AM
Re: Silverlight 2 DataGrid December 2008 Release

Can you advice or tell if DataGrid December 2008 source code will be made available as the previous MixControls version?

I am heavily using DataGrid features and made some derived extension classes which enables to drag and drop cell content between compatible column cells. I ran into some bugs with MixControls DataGrid version which I fixed in order to keep the development going.

Anyhow based on these derived classes I am a bit worried to swap into this new version as I am not certain how to mitigate if I would encounter bugs and I would not have source code available.

Regards, Alexander

AlexanderQX

Loading...
Joined on 02-24-2007
Posts 3
01-07-2009 1:08 PM
Re: Silverlight 2 DataGrid December 2008 Release

We are planning to release updated source code, and unfortunately I don't have a more specific answer than that, as it's still unclear when or how it will be released.  I understand your concern, though, and hopefully we can get something out soon.  We'll post more information as the plans develop.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
01-08-2009 4:18 AM
Re: Silverlight 2 DataGrid December 2008 Release

 Hello,

 Great work.What about filtering? Is it going to be implemented in a future release? Some news about this?

Thank you!

twinae

Loading...
Joined on 10-13-2008
Posts 19
01-08-2009 1:20 PM
Re: Silverlight 2 DataGrid December 2008 Release

To do this on the data side today, you would need a datasource that raises INotifyCollectionChanged.Reset when items are filtered.  In the SL 3 timeframe, there will be a CollectionView to assist with that.  You'll be able to add a Filter to it.

The UI side is less predictable.  After the data side supports it, it'll likely happen at some point, but it's still up in the air

Yifung Lin [MSFT]

yifung

Loading...
Joined on 03-25-2008
Redmond, WA
Posts 391
01-12-2009 10:46 PM
Re: Silverlight 2 DataGrid December 2008 Release

I have a vista system  This is what is listed (files listed below  under program files) in my computer files. My version was installed in october

2.0 31005.0  I already have a test project in expression blend that does not use this

What is the best way to unistall these just go thru that path and unistall ?

I really do not need my test project so I may delete this anyway

Should I delete  data design also?????? Thank you for your help.....

  • %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.Windows.Controls.Data.dll
  • %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.Windows.Controls.Data.Design.dll
billsm

Loading...
Joined on 03-31-2008
Posts 340
01-12-2009 11:10 PM
Re: Silverlight 2 DataGrid December 2008 Release

billsm:

I have a vista system  I can not find the proper path

Can I just delete this in expression blend

I can not seem to find the proper path on my computer ????

PLease advice me thank you......

I would like to install this.... 

Could you make sure hidden files and folders are shown?  In Explorer: Tools (Alt-T)->Folder Options->View->Show hidden files and folders

Yifung Lin [MSFT]

yifung

Loading...
Joined on 03-25-2008
Redmond, WA
Posts 391
01-12-2009 11:17 PM
Re: Silverlight 2 DataGrid December 2008 Release

I found this under program files in vista as the article described previously-exactly the same path

under programFiles: My files are like this:  version 2.0 31005.0 Oct----download

  • %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.Windows.Controls.Data.dll
  • %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.Windows.Controls.Data.Design.dll
billsm

Loading...
Joined on 03-31-2008
Posts 340
01-12-2009 11:41 PM
Re: Silverlight 2 DataGrid December 2008 Release

yifung ...............................I checked user folder nothing yes I went throught and unchecked hidden folder nothing

My path is listed same as described above....Program files etc

 

Please advice How can I delete these off my system..??????

Thank you

billsm

Loading...
Joined on 03-31-2008
Posts 340
01-13-2009 8:46 AM
Re: Silverlight 2 DataGrid December 2008 Release

I made a mistake!!!! I found the proper path users/username/appdata/local

I will delete this I will follow the directions above

Thank you for this post.......case closed...

billsm

Loading...
Joined on 03-31-2008
Posts 340
01-14-2009 7:56 AM
Re: Silverlight 2 DataGrid December 2008 Release

How about the bugs or drawbacks related to DataGridColumn.Header. In SL2 Beta it was possible to assign any UserControl to Header.Content property, but now it accepts only String.

Also it is impossible to build the DataGridTemplateColumn in code, as an object. One way is making StaticResource control with static binding properties in UserControl.Resource, another way is manually generate XAML code and parse it. In latter method it is not possible to add events to controls generated from XAML code. That makes serious problem when user needs to have a special field with buttons doing some function.

desmonduz85

Loading...
Joined on 10-24-2008
Posts 42
01-14-2009 1:32 PM
Re: Silverlight 2 DataGrid December 2008 Release

desmonduz85:

How about the bugs or drawbacks related to DataGridColumn.Header. In SL2 Beta it was possible to assign any UserControl to Header.Content property, but now it accepts only String.

Also it is impossible to build the DataGridTemplateColumn in code, as an object. One way is making StaticResource control with static binding properties in UserControl.Resource, another way is manually generate XAML code and parse it. In latter method it is not possible to add events to controls generated from XAML code. That makes serious problem when user needs to have a special field with buttons doing some function.

In Silverlight2, the DataGridColumn.Header cannot be a visual element, only a primitive (string, int, etc.).  If you want to add a visual element to the column header, you need to do so in the HeaderStyle.  Scott Morrison has a blog post that outlines the breaking changes between the Beta2 version and the first official release.

The DataGridTemplateColumn requires a template.  You must first define your DataTemplates in XAML, after which you can create the column itself in code and set the corresponding CellTemplate and CellEditingTemplate properties.  You can subscribe to events on the elements in the DataTemplates as you would any other element in XAML.

DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
templateColumn.Header = "MyDate";
templateColumn.CellTemplate = LayoutRoot.Resources["cellTemplate"] as DataTemplate;
templateColumn.CellEditingTemplate = LayoutRoot.Resources["cellEditingTemplate"] as DataTemplate;
dataGrid.Columns.Add(templateColumn);
<Canvas.Resources>
    <DataTemplate x:Key="cellTemplate">
        <TextBlock Text="{Binding MyDate}"/>
    </DataTemplate>
    <DataTemplate x:Key="cellEditingTemplate">
        <control:DatePicker SelectedDate="{Binding MyDate, Mode=TwoWay}" SelectedDateChanged="MyEventHandler"/>
    </DataTemplate>
</Canvas.Resources>
 
Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
01-14-2009 2:22 PM
Re: Silverlight 2 DataGrid December 2008 Release

Please reply to this thread only for issues related to the December 2008 DataGrid release.  General questions about the DataGrid will get better attention if you create a separate post for them.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
01-14-2009 8:37 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

 But the real issue is that programmer cannot create the DataTemplate object in code or access its child control. We have to create an DataTemplate with its explicit databinding in XAML. There is no way to do this dynamically.

Another method, which constructs the code-generated XAML and parses it, it lacks events. So the elements created in this way cannot be assigned to events.

 Generally speaking, I cannot understand the trends in Microsoft. Instead of making the layers more loosely connected, they made everything dependent on each other. DB is totally dependent on DataAccess objects, so any change in DB table should be manually replicated in DataAccess layer, then in Presentation layer too, as every columns is specified in DataGrid.

I want to create columns dynamically, and I don't know how to create column with buttons where the binding for this column should be set in code, not explicitly in XAML. 

desmonduz85

Loading...
Joined on 10-24-2008
Posts 42
01-14-2009 9:13 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

If you want to set the binding of a control within the DataTemplate, you could subscribe to its Loaded event and set it up in the handler.  The control will automatically inherit the Row's DataContext. 

<Canvas.Resources>
    <DataTemplate x:Key="cellTemplate">
        <Button Loaded="Button_Loaded"/>
    </DataTemplate>
</Canvas.Resources>
private void Button_Loaded(object sender, RoutedEventArgs e)
{
    Button button = sender as Button;
    if (button != null)
    {
        Binding binding = new Binding("MyPropertyName");
        binding.Mode = BindingMode.OneWay;
        button.SetBinding(Button.ContentProperty, binding);
    }
}
 
Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
01-14-2009 9:50 PM
Re: Re: Re: Silverlight 2 DataGrid December 2008 Release

Usually I can specify the binding while I am adding the columns, because I know which column I am adding right now. In this solution, is it possible to know where this button is loaded? I can have many columns with buttons, but how I can specify the binding for them, as I don't know which button is loaded.

As regards the DataGridColumn header, I can only bind the header title to my custom UIControl, but what if I need to bind some more properties, too. For example, I also need to keep the DisplayMemberPath of Column in Tag property of my custom UIControl so it can accomplish some sort or filter operations with database. I would love to use the method above, but please tell me the way how I can identify the current column where the button is loaded.

desmonduz85

Loading...
Joined on 10-24-2008
Posts 42
02-04-2009 12:12 AM
Re: Silverlight 2 DataGrid December 2008 Release

Hi guys, I have been using the DataGrid to simulate a ListBox in multi-selection mode.  But, since I installed the December Release, I cannot select my items programmatically anymore.

When I invoke the DataGrid.SelectedItems.Add(object value) method nothing happens, and the Count property stays at 0.

Any ideas?

Thanks,

-Johan

 

johonline

Loading...
Joined on 09-17-2008
Posts 6
02-10-2009 3:36 AM
Re: Silverlight 2 DataGrid December 2008 Release

johonline:

Hi guys, I have been using the DataGrid to simulate a ListBox in multi-selection mode.  But, since I installed the December Release, I cannot select my items programmatically anymore.

When I invoke the DataGrid.SelectedItems.Add(object value) method nothing happens, and the Count property stays at 0.

Any ideas?

Thanks,

-Johan

 

 

 

Sorry for the slow response.  I just got this release re-installed and it seems to work fine for me.  If you're still running into this issue, are there any more details you can provide? When are you calling SelectedItems.Add?  Is SelectionMode set to Extended or Single?

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
02-10-2009 4:11 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

 

billsm

Loading...
Joined on 03-31-2008
Posts 340
02-10-2009 4:14 PM
Re: Silverlight 2 DataGrid December 2008 Release

 

billsm

Loading...
Joined on 03-31-2008
Posts 340
02-10-2009 7:04 PM
Re: Silverlight 2 DataGrid December 2008 Release

My SelectionMode is set to Extended (default value), here is the code I use:

Day Selector Xaml code:

            <data:DataGrid x:Name="DayMaskList" HeadersVisibility="Row" AutoGenerateColumns="False">
                <data:DataGrid.Columns>
                    <data:DataGridTemplateColumn>
                        <data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding}" />
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellTemplate>
                    </data:DataGridTemplateColumn>
                </data:DataGrid.Columns>
            </data:DataGrid>

Day Selector Initialization code: 

            var days = (from field in typeof(DayOfWeek).GetFields() where field.IsLiteral select field.Name).ToList<string>();
            DayMaskList.ItemsSource = days;
            foreach (object item in DayMaskList.ItemsSource) DayMaskList.SelectedItems.Add(item); 

With the previous version of the DataGrid, this code allowed me to select all items programmatically.  Now, only the last item is selected...  The foreach loop does not add anything to the SelectedItems collection.

johonline

Loading...
Joined on 09-17-2008
Posts 6
02-13-2009 2:31 PM
Re: Silverlight 2 DataGrid December 2008 Release

It seems to break our styles for datagrids. Seems like the sort shows up when it didn't before. Here's a screenshot:
http://www.flickr.com/photos/27316914@N04/3276473967/

Noting that CanUserSortColumns is false. Seems like the Datagrid is outputting the sort style for some reason.

Noting we're using DataGridTemplateColumn. Here's an example of one:

<my:DataGridTemplateColumn Width="122" Header="Country" CellStyle="{StaticResource DataGridCellStyle}">
  <my:DataGridTemplateColumn.HeaderStyle>
    <Style TargetType="localprimitives:DataGridColumnHeader">
      <Setter Property="Padding" Value="0" />
      <Setter Property="Margin" Value="0" />
      <Setter Property="Height" Value="31" />
      <Setter Property="MaxHeight" Value="31" />
      <Setter Property="MinHeight" Value="31" />
      <Setter Property="Width" Value="122" />
      <Setter Property="Background" Value="Transparent" />
      <Setter Property="BorderThickness" Value="0" />
      <Setter Property="ContentTemplate">
        <Setter.Value>
          <DataTemplate>
            <Grid Margin="0" MaxHeight="31" MinHeight="31" Height="31" Width="122" Background="#FFFBE4AB" Cursor="Hand" >

              <Grid.RowDefinitions>
                <RowDefinition Height="1" />
                <RowDefinition Height="24" />
                <RowDefinition Height="1" />
                <RowDefinition Height="1" />
                <RowDefinition Height="1" />
                <RowDefinition Height="1" />
                <RowDefinition Height="1" />
                <RowDefinition Height="1" />
              </Grid.RowDefinitions>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>

              <Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="White" />

              <Grid Background="Black" Grid.Column="0" Grid.Row="1" MaxHeight="24" MinHeight="24" Height="24">
                <TextBlock Text="{Binding}" Foreground="White" MouseLeftButtonDown="Sort_Click" Tag="Country" Margin="3,4,0,0" VerticalAlignment="Center" FontWeight="Normal" />
              </Grid>

              <Rectangle Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="White" />
              <Rectangle Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="Black" Opacity="0.81" />
              <Rectangle Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="Black" Opacity="0.65" />
              <Rectangle Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="Black" Opacity="0.49" />
              <Rectangle Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="Black" Opacity="0.33" />
              <Rectangle Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2" Height="1" Width="122" Fill="Black" Opacity="0.16" />
            </Grid>
          </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </my:DataGridTemplateColumn.HeaderStyle>
  <my:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding Country}" Margin="4" VerticalAlignment="Top" TextWrapping="Wrap" />
    </DataTemplate>
  </my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
 
Harlequin

Loading...
Joined on 06-11-2008
Vancouver, B.C.
Posts 142
02-16-2009 5:09 PM
Re: Silverlight 2 DataGrid December 2008 Release

p.s. This is for an internal project for Microsoft themselves, so not good if I need to hack this datagrid even more than I've had to to make things work :)

Harlequin

Loading...
Joined on 06-11-2008
Vancouver, B.C.
Posts 142
02-16-2009 6:03 PM
Re: Silverlight 2 DataGrid December 2008 Release

Yes, the new header style always leaves room for the sort icon.  You'll have to retemplate the header itself (not just it's ContentTemplate) to remove it.  For example, you could make the header's style only consist of the content by adding the following setter to your header style:

<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="localprimitives:DataGridColumnHeader">
            <ContentPresenter
                Content="{TemplateBinding Content}"
                Cursor="{TemplateBinding Cursor}" />
        </ControlTemplate>
    </Setter.Value>
</Setter>
Also, it looks like you're hard-coding the width, in which case you might also want to turn off column resizing or you'll get some odd behavior when people try to resize the columns.  There are some optimizations you can make to your Xaml, as well.  If you remove the instances where you're setting default values (i.e. Grid.Column="0" or Margin="0") you'll save the xaml parser some work.  You should probably get rid of the ColumnSpan="2" settings, too, because they don't make sense when there's only one column.
Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
02-17-2009 10:42 AM
Re: Silverlight 2 DataGrid December 2008 Release

Since we had set column widths we had to hack the setter properties:
<Setter Property="Width" Value="122" />
...we had to add 15 to this width in order to "push" this sort thing behind the other column so it isn't viewable anymore.

Not sure what you mean by "new header style". New as to this release? Not sure why it isn't in the list of "breaking changes" then if it is. My current styles in the app.xaml have no sorting rectangle in there whatsoever. It seems like our DataGridTemplateColumn.HeaderStyle is getting some default sorting thing in there as you can see in the flickr image. Not sure where this is coming from, since it's not in our styles from before.

Edit: So you're saying, even though we have the DataTemplate in there, I need to add your ControlTemplate code in as well to remove the sorting thing? I see where you're going, but I have CanSort as False in each of the columns themselves, and the entire grid, should setting sorting to "no" stop this sorting rectangle from rendering?

Harlequin

Loading...
Joined on 06-11-2008
Vancouver, B.C.
Posts 142
02-17-2009 1:18 PM
Re: Silverlight 2 DataGrid December 2008 Release

What you say in your edit is correct; that's what I meant, sorry if I wasn't very clear.  The header template essentially has three main components: the content presenter (which can be re-templated through the ContentTemplate), the sort icon, and the vertical separator.  Currently, in order to remove the sort icon you have to remove it from the header template itself.

I understand what you're saying about leaving the space there for the sort icon even though CanSort is false.  We had decided to always leave room there in order to avoid having to dynamically change the column's width when the sort icon appears or the value of CanSort changes during runtime.  I'll discuss this with my team and see if we should remove the extra space when CanSort is false, but the only way around this (at least for right now) is to re-template the header.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
02-17-2009 2:26 PM
Re: Silverlight 2 DataGrid December 2008 Release

But I also already have the ControlTemplate in my App.xaml for my DataGridColumnHeader, all I'm doing in the DataGrid is setting the DataTemplate. Should the ContentTemplate not trickle down, or when you do things like overriding the DataGridTemplateColumn.HeaderStyle is the rul that you need to override everything, including the ControlTemplate. This is what I would expect, unless it's a Silverlight limitation to do so.

Harlequin

Loading...
Joined on 06-11-2008
Vancouver, B.C.
Posts 142
02-18-2009 1:38 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

Having the exact same issue as johonline where in some cases, adding items to the selecteditems collection does not do anything as DataGrid.SelectedItems.Count returns 0 after calling Add() and the last object in our loop is all that is selected. We aren't trying to select all items as in johonline's case but this is still proving to be a MAJOR headache for us. It seems to work all but the first time we try it.

 Has there been any workaround to this issue or is it a confirmed bug that is being worked on?

TSmooth

Loading...
Joined on 01-08-2007
Posts 10
02-18-2009 3:27 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

This is not a bug we have been aware of prior to this discussion.  It sounds pretty serious, though, so I'll continue to try and reproduce it.  Thanks for bringing it to our attention.  I'll post something when I figure out what's wrong.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
02-18-2009 3:40 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

I was just able to reproduce this locally.  It looks like it occurs if you try to select items during the initialization phase.  I have an idea of what might be causing this so I'll try to get it fixed for the next version.  There is something you can do to workaround this issue in the meantime.  If you delay your selection code so that it doesn't run until after the rows have loaded, it should fix this problem.  One way to do this is to wrap your selection code in a call to Dispatcher.BeginInvoke.  Let me know if that works as a temporary solution.  Thanks again for bringing this to our attention.

Dispatcher.BeginInvoke(delegate
{
    for (int i = 0; i < 15; i++)
    {
        this.dataGrid.SelectedItems.Add(data[ i ]);
    }
});
Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
02-19-2009 9:43 AM
Re: Re: Silverlight 2 DataGrid December 2008 Release

Brian,

Your workaround seems to work in one of the applications I'm working on that was experiencing this issue so thank you for that. I'll keep testing it to make sure the issue really is gone. However, I put together a small project to test this issue and found that the bug (or a slightly different one) occurs when you set the selecteditems property while the datagrid's visibility is collapsed to start with. In that case, only the last item in the loop is selected and your workaround does not appear to work unless I'm doing something wrong. I created a sample project to demonstrate this issue and have put the project in my skydrive for you to take a look at: http://cid-0af87538a5b43838.skydrive.live.com/self.aspx/.Public/DataGridSelectedItemsTest.zip 

If you click on either of the "Selection" buttons and then click the toggle datagrid button, you will see that only one item is selected where in each case, 2 should be selected. If you toggle the datagrid first and then click either of the selection buttons you will see that it works fine. The last button added was your work around which doesn't seem to work in this case unless I implemented it incorrectly. Once the datagrid has been made visible, it seems to work anytime after that regardless of whether or not the datagrid is visible.

 Expected behavior: You should be able to set the selected items collection regardless of whether or not the datagrid is visible.

On a separate but related issue, I'd like to mention a request for the selected items collection to be bindable. That would help out a LOT in our situation.

 Thanks for your help and replies, Brian!

-Tom

TSmooth

Loading...
Joined on 01-08-2007
Posts 10
02-23-2009 5:44 PM
Re: Silverlight 2 DataGrid December 2008 Release

The December release fixed a lot of issues I was having, but there is still a persistant problem with having the DataGrid appear within a Popup.

What I am finding is that the moment the Popup appears away from the top left corner (0 x, 0 y), the column resize functionality overrides the column sort and reorder functionality.  Basically you have the WE cursor over the entire column header, so theres no way to reorder columns or click through to the sort option.

Looking at the source code thrown up by Reflector, it appears that the resize function uses the header width minus the mouse x position to determine whether or not the mouse is < 5 pixels from the header's edge.  If so the resize cursor and function is shown/enabled.

I think because the datagrid is in a popup, the mouse co-ordinates it is using in the above resize enabling function are actually relative to the Silverlight host within the browser window, rather than being relative to the Popup.  e.g. if the Popup is 500 pixels from the left, then mouse x position is always > 500.
Thus the resulting column header size minus mouse x position calculation is always less than 5 pixels (think -400), and the resize is permanently enabled.

 Anyhow this should be easy to fix - hope this can happen!

paupdb

Loading...
Joined on 09-29-2008
Brisbane, Australia
Posts 14
02-24-2009 9:26 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

tsmooth:

Brian,

Your workaround seems to work in one of the applications I'm working on that was experiencing this issue so thank you for that. I'll keep testing it to make sure the issue really is gone. However, I put together a small project to test this issue and found that the bug (or a slightly different one) occurs when you set the selecteditems property while the datagrid's visibility is collapsed to start with. In that case, only the last item in the loop is selected and your workaround does not appear to work unless I'm doing something wrong. I created a sample project to demonstrate this issue and have put the project in my skydrive for you to take a look at: http://cid-0af87538a5b43838.skydrive.live.com/self.aspx/.Public/DataGridSelectedItemsTest.zip 

If you click on either of the "Selection" buttons and then click the toggle datagrid button, you will see that only one item is selected where in each case, 2 should be selected. If you toggle the datagrid first and then click either of the selection buttons you will see that it works fine. The last button added was your work around which doesn't seem to work in this case unless I implemented it incorrectly. Once the datagrid has been made visible, it seems to work anytime after that regardless of whether or not the datagrid is visible.

 Expected behavior: You should be able to set the selected items collection regardless of whether or not the datagrid is visible.

On a separate but related issue, I'd like to mention a request for the selected items collection to be bindable. That would help out a LOT in our situation.

 Thanks for your help and replies, Brian!

-Tom

Yeah, you're right that the workaround won't fix the issue if the DataGrid isn't visible.  You'll have to tweak it a little bit by setting selection when the DataGrid becomes visible (you might also have to BeginInvoke the selection code here as well) -- as long as you're in control of when the visibility changes, or can find out when it happens.

The reason the workaround doesn't work in this case (if you're curious) is that adding multiple items to the DataGrid is broken while the rows are being loaded.  There's a time period between when you set the ItemsSource and the DataGrid finishes loading all of the visual elements.  It's this time period in which you can't properly set selection -- that's the bug.  The original workaround works in most cases because the BeginInvoke pushes the selection code to the end of the queue so that it doesn't run until after the DataGrid has been arranged/measured completely, but it won't work if it isn't visible because the rows won't finish loading until they're actually rendered.

For SelectedItems, I'll bring it to the attention of the feature crew, but it's currently a readonly property and making it bindable could add some complications.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
02-25-2009 5:17 PM
Re: Re: Re: Silverlight 2 DataGrid December 2008 Release

Thanks for the tip, it solved our issue.

johonline

Loading...
Joined on 09-17-2008
Posts 6
03-12-2009 4:17 PM
Re: Silverlight 2 DataGrid December 2008 Release
I'm having a drawing issue when using a checkbox in a DataGridTemplateColumn. When I have something like >40 rows and I have to scroll down to see the remaining rows and then scroll back up, visually some of the checkboxes will change state i.e. if check become unchecked, if unchecked becomes checked. I can reproduce the same behavior if I use the ToggleButton or a Button as well. It seems almost as if the content of the template cell is changing when scrolling.
pstatho

Loading...
Joined on 08-31-2006
Posts 21
03-18-2009 3:41 PM
Re: Silverlight 2 DataGrid December 2008 Release

i have followed those steps exactly,(btw the 4 toolbox files where hidden ) now in my silverlight project oolbox i have no controls :S i only have the grid and the datepicker. the others controls are there but only when i sleect show all(inactive). i tried with devenv /resetskipkgs and /resetsettings and /setup, but nothings happens.

whats worng???. now im installing the silverlight 3 beta toolbox to see if this get repaired, thanks.

shinji14

Loading...
Joined on 07-18-2005
Lima Peru
Posts 19
03-23-2009 9:41 PM
Re: Silverlight 2 DataGrid December 2008 Release

Does the RIA Serivces Announcement give us a rough timeline as to when virtual mode for the DataTable will be ready?  Is there any expected relation between the two?

Chris

makerofthings

Loading...
Joined on 04-22-2008
Posts 18
03-30-2009 3:07 PM
Re: Silverlight 2 DataGrid December 2008 Release

Did silverlight 3 beta fix your problem?

 

shipn

Loading...
Joined on 03-30-2009
Posts 5
03-30-2009 5:22 PM
Re: Silverlight 2 DataGrid December 2008 Release

Yes, silveright 3 solved my problems, buyt added a few ones, like i have to rebuild the solution to have debug available.

shinji14

Loading...
Joined on 07-18-2005
Lima Peru
Posts 19
04-08-2009 6:33 PM
Re: Silverlight 2 DataGrid December 2008 Release

Hi,

It seems the datagrid is very slow to display data, even with a reasonnable amount of lines (50 lines, 5 to 10 columns).

It takes more than one second to display a collection (binded by setting itemsource property), with listbox it only takes 400 to 500 ms. And with 10 years old asp 3 it takes less than 100 ms ;)

Maybe I missed something but It seems to be a known issue (http://silverlight.net/forums/p/19917/202710.aspx, http://silverlight.net/forums/p/77822/183862.aspx), can we expect improvements ?

 

Thanks,

Gengis

Loading...
Joined on 11-11-2008
Posts 8
04-10-2009 2:04 PM
Re: Silverlight 2 DataGrid December 2008 Release

I personally think that the instructions on the download page are BS.  You are making folks remove all of their toolbox mappings for every stinking control that they use?  This was a very lazy approach to pushing out these changes, IMHO.  It should have been delivered with an MSI, but I guess I should expect nothing less than mediocrity from Microsoft.

Alan

flashfearless

Loading...
Joined on 04-06-2007
Posts 6
04-10-2009 3:31 PM
Re: Silverlight 2 DataGrid December 2008 Release

Gengis - There isn't much more I can add than what Yifung has said in the threads you reference.  The DataGrid is a more complex control than ListBox, and chances are that there are many more visuals being created when it loads.  A DataGrid with 50 rows and 10 columns is like having 10 ListBoxes with 50 items each.  One benefit of the DataGrid, however, is that it virtualizes its rows, so the initial load time is dependent on the number of visible elements rather than the number of items in the ItemsSource -- the ListBox will create visual elements for all of its items, even if they are scrolled out of view.  Having said all of that, though, the SL3 DataGrid should have faster load times than it did with SL2.  Have you had a chance to try the SL3 beta yet?

Alan - I'm sorry you had to lose your toolbox mappings when you upgraded the DataGrid.  We wanted to get a new version out for you guys quickly, and I apologize if it was inconvenient.  Thanks for the feedback.

Brian Braeckel

Loading...
Joined on 09-03-2008
Posts 46
04-10-2009 9:22 PM
Re: Re: Silverlight 2 DataGrid December 2008 Release

Brian : I followed Yifung's suggestion, putting the datagrid in a grid (with Grid.Row and Grid.Column) is cleary better than putting it in a StackPanel. Not as fast as a listbox but not so far. I think that mixing StackPanel and DataGrid should be more clearly discouraged.

Maybe it's off topic but I do not understand why SL still does not meet all the basic needs of a business application, trivial  feature like 'field validation' or 'having a first item blank in a ComboBox' or 'handling wcf exceptions or fault' are not provided out of the box. When you come from asp.net it is a bit confusing to see that such simple features are missing, for each of them you waste time at searching on the web if you did not miss something and then you waste time at implementing them yourself in the less ugly manner.

Gengis

Loading...
Joined on 11-11-2008
Posts 8
04-25-2009 11:06 PM
CollectionView in Silverlight 3

Does anyone know if the System.Windows.Data.CollectionView class is included with Silverlight 3? I don't see it in the Beta documentation. That will be a shame if it's still missing in Silverlight 3 RTM. 

jemiller

Loading...
Joined on 01-04-2006
Posts 176
04-27-2009 2:02 PM
Re: CollectionView in Silverlight 3

In Silverlight 3, there is a PagedCollectionView that is a CollectionView implementation that does paging as well.  In the SL 3 Beta, it is in the System.ComponentModel.dll that comes with the SDK; however, in the RTM release of SL 3, it will be in the System.Windows.Data.dll.

Field validation is available in Silverlight 3 using the same DataAnnotations attributes that are available for ASP.NET.  I thought the ComboBox already has nothing selected (blank item) by default.

Yifung Lin [MSFT]

yifung

Loading...
Joined on 03-25-2008
Redmond, WA
Posts 391
04-28-2009 5:26 PM
Re: Re: CollectionView in Silverlight 3

@yifung : the blank list item is selected by default but as soon as you select another item (one provided by in the ItemsSource) it becomes unavailable. So you have to insert a new instance at the first position of your list before setting the items source.

Concerning the validation : do you consider an alternative to the DataAnnotations ? How would you apply validation when entities are local representations of remote objects (typically in a silverlight <=> wcf application) ? Would you directly work on the generated classes (in reference.cs) ?! In this case validation through xaml control (like requiredFiledValidator) seems more suitable.

And by the way thanks for Fault support and binaryHttpBinding.

Gengis

Loading...
Joined on 11-11-2008
Posts 8
05-18-2009 7:38 PM
Re: Re: Re: CollectionView in Silverlight 3

Thanks for this update, I was having the issue when removing rows from my DataGrid that empty rows would appear and this fixed it!

Justin Toth
Toth Solutions
Justin Toth's Blog

justintoth

Loading...
Joined on 05-14-2009
Cockeysville, MD
Posts 96
07-03-2009 11:07 AM
Stick out tongue [:P]Re: Silverlight 2 DataGrid December 2008 Release
<p></p>
ossc_webapp

Loading...
Joined on 07-02-2009
Posts 861
07-03-2009 11:08 AM
Stick out tongue [:P]Re: Re: Re: Silverlight 2 DataGrid December 2008 Release
<p></p>
ossc_webapp

Loading...
Joined on 07-02-2009
Posts 861
07-03-2009 11:09 AM
Stick out tongue [:P]Re: Re: CollectionView in Silverlight 3
<p></p>
ossc_webapp

Loading...
Joined on 07-02-2009
Posts 861
07-03-2009 11:10 AM
Re: Re: CollectionView in Silverlight 3
<p></p>
ossc_webapp

Loading...
Joined on 07-02-2009
Posts 861
Microsoft Communities