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

  • SEARCH
  • Home
  • 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 982073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:38:22+00:00 2026-05-16T04:38:22+00:00

i am trying to list data from a webservice in a datagrid (wpf), but

  • 0

i am trying to list data from a webservice in a datagrid (wpf), but i dont know what i doing wrong, or gives me errors or dont list anything.
This is how i have right now.

WINDOWS.XAML

<Window x:Class="IssueAddinOutlook.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
    Title="Issue List" Height="424" Width="696">

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="102*" />
        <ColumnDefinition Width="590*" />
    </Grid.ColumnDefinitions>
    <Label Height="41" Margin="172,0,265,0" Name="label1" VerticalAlignment="Top" FontSize="22" Grid.Column="1">Issue List</Label>

    <dg:DataGrid x:Name="dataGrid" AutoGenerateColumns="True"
         AlternationCount="2"

         HeadersVisibility="All"
         HorizontalGridLinesBrush="#DDDDDD"
         VerticalGridLinesBrush="#DDDDDD" Grid.ColumnSpan="2" Margin="0,0,28,26">

        <dg:DataGrid.Columns>
            <dg:DataGridTextColumn Header="ID Issue" Binding="{Binding Path=Id}" />
            <dg:DataGridTextColumn Header="Order Id" Binding="{Binding Path=OrderId}" />
            <dg:DataGridTextColumn Header="Is Done" Binding="{Binding Path=IsDone}" />
            <dg:DataGridTextColumn Header="Final Comment" Binding="{Binding Path=FinalComment}" />
            <dg:DataGridTextColumn Header="Actual Hours" Binding="{Binding Path=ActualHours}" />
            <dg:DataGridTextColumn Header="Group Id" Binding="{Binding Path=GroupId}" />
        </dg:DataGrid.Columns>
    </dg:DataGrid>
</Grid>
<Window.Resources>
    <Style x:Key="columnHeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="Navy" Offset="0" />
                        <GradientStop Color="LightBlue" Offset="1" />
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="White" />
    </Style>
    <Style x:Key="rowStyle" TargetType="dg:DataGridRow">
        <Setter Property="FontFamily" Value="Verdana" />
        <Setter Property="FontSize" Value="10" />
        <Style.Triggers>
            <Trigger Property="AlternationIndex" Value="0">
                <Setter Property="Background" Value="White" />
            </Trigger>
            <Trigger Property="AlternationIndex" Value="1">
                <Setter Property="Background" Value="#DDDDDD" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="#BBBBBB" />
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>

And the WINDOWS.XAML.CS

 Issuereference.Tasks issueRef = new Issuereference.Tasks();
 Issuereference.TASK[] tasksList = issueRef.GetTasks(39);
 dataGrid.ItemsSource = tasksList.ToList();

with this code gives the error Items collection must be empty before using ItemsSource.
Can anyone help me?

  • 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-05-16T04:38:22+00:00Added an answer on May 16, 2026 at 4:38 am

    Your code seems to work fine. Anyway, assigning the ItemsSource, is there anything that appears already inside the grid? Or is there any part of the application that manually adds items to the DataGrid? That error message usually means that a part of the application has updated the ItemsControl’s collection while it has an assigned ItemsSource. Hope this makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access data from list view using columnheader name but I
i am trying to download data from a sharepoint list from a C# application.
Im trying to create LinqDataSource that will represent data from dynamically created String list
I'm trying to populate a drop down list with data from an SQL database
Trying to create a list to return some JSON data to a view. Following
I'm trying to bind a list of custom objects to a WPF Image like
I am trying to sort a list using delegates but I am getting a
I have a list of webservices from a Flex project. I am trying to
While trying to extract data from a view by joining it with two other
I am trying to extract data from XML file and save it my C#

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.