locked
dataGrid.Columns.Count() in Silverlight RRS feed

  • Question

  • Hello,

    In my Silverlight application I am trying to count columns in the dataGrid after the ItemsSource has been set (dataGridView.ItemsSoutce=e.Result - it's from the service). This fills the dataGrid, but the count result is always "0". How that might be and how can I get a trueth result?

    Thanks.

    Friday, April 29, 2011 6:42 PM

All replies

  • If you are auto generating the columns from the item source this will be zero. The count coming back there is the count of columns that you have defined on the data grid.
    Devlin Liles http://twitter.com/devlinliles http://www.devlinliles.com/ If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Saturday, April 30, 2011 12:28 AM
  • Yes, You're right, thank you.

    Still I have a problem  - there is no "IsPostBack" in Silverlight "MainPage.xaml.cs". How I can get feedback from aspx testPage when it deploys?

    Thanks.

    Saturday, April 30, 2011 10:06 AM
  • Hi Leozel,

    Welcome to the MSDN fourm.

    The silverlight is a client application and The IsPostBack is the concept in the asp.net.

    But you can capture the first load function instead.

    private bool _isRecurLoad;

    public void MainPage()

    {

    this.Loaded += new RoutedEventHandler(OnLoaded);

    }

    private void OnLoaded(object sender, RoutedEventArgs e)

    {

    if ( !_isRecurLoad)

    {

    _isRecurLoad = true;

    }

    }

     

    I hope that would be help you.

    Best Regards.


    If it's helpful for you, Please vote or mark. Thank you!

    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by leozel Saturday, May 7, 2011 4:30 PM
    • Unmarked as answer by leozel Saturday, May 7, 2011 5:53 PM
    Monday, May 2, 2011 6:30 AM
  • Hello leozel,

    Thanks for your post.

    If you have any time, could you please tell me if David's suggestion works? If it does, please mark it as answer. Or please feel free to tell me if you have any questions.

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 5, 2011 3:21 AM
  • Hello David, Hello Jackie-Sun,

    Excuse me for some delay.

    David,

    Where I have to declare the "private bool _isRecurLoad;"?

    Just every time the page is loading, it gets the default of "faulse".

    leozel.

     

    Saturday, May 7, 2011 4:32 PM