Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:12:37+00:00 2026-06-06T01:12:37+00:00

I am developing a silverlight application where you can set sales target for specific

  • 0

I am developing a silverlight application where you can set sales target for specific kind of product.
I have a combobox which has some product types in it like Rice , Tea etc. Once you select a type, all products of that type gets loaded into a datagrid with following info:
Product Name, Session(this is the time for which the target is going to be activated,selected using a datepicker before,and added to datagrid as string), Target Amount.
I have defined the datagrid like below:

<sdk:DataGrid x:Name="productListGrid" Margin="8,117,8,8" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" CellStyle="{StaticResource DataGridCellStyle}" RowHeight="50" AutoGenerateColumns="False">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Binding="{Binding ProductName}" CanUserSort="True" CanUserReorder="True" CellStyle="{x:Null}" CanUserResize="True" ClipboardContentBinding="{x:Null}" DisplayIndex="-1" DragIndicatorStyle="{x:Null}" EditingElementStyle="{x:Null}" ElementStyle="{x:Null}" Foreground="{x:Null}" FontWeight="Normal" FontStyle="Normal" FontSize="NaN" HeaderStyle="{x:Null}" Header="Name" IsReadOnly="False" MaxWidth="Infinity" MinWidth="0" SortMemberPath="{x:Null}" Visibility="Visible" Width="Auto"/>
                <sdk:DataGridTextColumn Binding="{Binding Session}" CanUserSort="True" CanUserReorder="True" CellStyle="{x:Null}" CanUserResize="True" ClipboardContentBinding="{x:Null}" DisplayIndex="-1" DragIndicatorStyle="{x:Null}" EditingElementStyle="{x:Null}" ElementStyle="{x:Null}" Foreground="{x:Null}" FontWeight="Normal" FontStyle="Normal" FontSize="NaN" HeaderStyle="{x:Null}" Header="Session" IsReadOnly="False" MaxWidth="Infinity" MinWidth="0" SortMemberPath="{x:Null}" Visibility="Visible" Width="Auto"/>
                <sdk:DataGridTextColumn Binding="{Binding TargetQuantity, Mode=TwoWay}" CanUserSort="True" CanUserReorder="True" CellStyle="{x:Null}" CanUserResize="True" ClipboardContentBinding="{x:Null}" DisplayIndex="-1" DragIndicatorStyle="{x:Null}" EditingElementStyle="{x:Null}" ElementStyle="{x:Null}" Foreground="{x:Null}" FontWeight="Normal" FontStyle="Normal" FontSize="NaN" HeaderStyle="{x:Null}" Header="Target Quantity" IsReadOnly="False" MaxWidth="Infinity" MinWidth="0" SortMemberPath="{x:Null}" Visibility="Visible" Width="Auto"/>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

I have a class that represents each row:

public class DataGridRow
        {
            public string ProductName{get;set;}
            public string Session { get; set; }
            public string TargetQuantity { get; set; }

        }

And then using the following method I set itemssource of the datagrid:

private void initDataGrid(string product_type)
        {
            List<DataGridRow> rows = new List<DataGridRow>();
            if (start.Equals(NullDate) || end .Equals(NullDate))
            {
                MessageBox.Show("Please select start and end date first!");
            }
            else
            {
                var products_list = _context.Products.Where(entity => entity.ProductType.Equals(product_type));

                var product_name_list = from product in products_list select product.ProductName;

                foreach (string name in product_name_list)
                {
                    rows.Add(new DataGridRow()
                    {
                        ProductName = name,
                        Session = this.Months[start.Month-1] + "," + start.Year + "->" + this.Months[end.Month-1] + "," + end.Year,
                        TargetQuantity = "0.0"
                    });
                }
                try
                {
                    this.productListGrid.ItemsSource = rows;
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

I have checked the list rows by a for loop if it was filled properly, and saw that it was.

This method is invoked once I select a product type from combo box:

private void productCombo_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            string product_type=(string)e.AddedItems[0];
            this.initDataGrid(product_type);
        }

But once I run the app and select something from the combobox the whole screen becomes blank.Then I commented out the line this.productListGrid.ItemsSource = rows; from initDataGrid method and then I could select items from combo except the datagrid left blank this time(usual actually, the itemssource is not set)
So it seems when I set the ItemsSource for DataGrid my silverlight app gets crashed. I have been struggling with it for few hours,searched Google & StackOF so many times,but no way… so I need help badly.

If any body can solve the problem please give a bit explanation too as I am new to silverlight and don’t want to make the mistake again due to lack of knowledge.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:12:39+00:00Added an answer on June 6, 2026 at 1:12 am

    Since you’re not giving an exception we don’t have much to go on. I would guess since you’re posting it here that there isn’t a specific line it’s breaking on then it’s probably a Xaml issue. For starters, try simplifying your datagrid’s columns. You’re setting a bunch of properties you have no business setting. I’m also noticing you’re setting DisplayIndex to -1 on each of them which I suspect is the issue.

    Try this:

    <sdk:DataGrid x:Name="productListGrid" Margin="8,117,8,8" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" CellStyle="{StaticResource DataGridCellStyle}" RowHeight="50" AutoGenerateColumns="False">
        <sdk:DataGrid.Columns>
            <sdk:DataGridTextColumn Binding="{Binding ProductName}" CanUserSort="True" CanUserReorder="True" CanUserResize="True" Header="Name" IsReadOnly="False" Width="Auto"/>
            <sdk:DataGridTextColumn Binding="{Binding Session}" CanUserSort="True" CanUserReorder="True" CanUserResize="True" Header="Session" IsReadOnly="False" Width="Auto"/>
            <sdk:DataGridTextColumn Binding="{Binding TargetQuantity, Mode=TwoWay}" CanUserSort="True" CanUserReorder="True" CanUserResize="True" Header="Target Quantity" IsReadOnly="False" Width="Auto"/>
        </sdk:DataGrid.Columns>
    </sdk:DataGrid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Silverlight application which has a list <ListBox x:Name=_list_collection SelectionChanged=SelectionChanged ScrollViewer.VerticalScrollBarVisibility=Auto
I'm developing a Silverlight 3 Application which I want to connect to a webservice
I'm developing a Silverlight application for the first time. I've gone through some tutorials,
I have a question on using MVVM within a Silverlight application I am developing.
I have been developing a Lync Silverlight application in Silverlight and now I am
I'm developing a Silverlight application, and want to set the ItemsSource of a ListBox
I'm developing a Silverlight Business Application, using a RIA service, which is returning POCO
I am developing silverlight application. I have a listbox in my application. I am
I'm developing a map application in Silverlight. I have a type Polygon, containing the
I'me currently developing a silverlight application. In this application, I've an exception handler which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.