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 7953155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:04:41+00:00 2026-06-04T03:04:41+00:00

I made a custom Class named MedinetParse that parses a webrequest. The parsed data

  • 0

I made a custom Class named MedinetParse that parses a webrequest. The parsed data should be showen in a listbox named mittSchemaListBox in the my MainPage. The problem that i’m facing now is that IF i write the parsing method in a custom class named MedinetParse the listbox showes nothing. Althought when i put a breakpoint at the very last line of code inside the parse method, i can see that mittSchemaListBox.ItemsSource have all the parsed items. Meanwhile if i move the parsing method into my MainPage.xaml.cs, then i will see all the parsed item in my listbox.

Here is my MedinetParsing class

namespace WindowsPhonePanoramaApplication1
{
public class MedinetParsing : MainPage
{
    //Defining class properties
    public string Placering { get; set; }
    public string Datum { get; set; }
    //Defining class methods
    public void parseResults(string myresponse)
    {
        if (string.IsNullOrEmpty(myresponse))
        {
            return;
        }

        //Initiating a listbox and add item to it
        List<ItemViewModel> mittSchemaList = new List<ItemViewModel>();
        //Using HtmlAgilityPack to parse the HTMLcode from the response
        HtmlDocument htdoc = new HtmlDocument();
        htdoc.LoadHtml(myresponse);
        foreach (HtmlNode table in htdoc.DocumentNode.SelectNodes("//table[@class='list-medium']/tbody[1]/tr[@class]"))
        {
            //Removing ChildNode
            table.ChildNodes.RemoveAt(3);
            string itemValue = table.InnerText;
            //Changing the parsed date into a DateTime
            string d;
            DateTime datum = DateTime.Parse(itemValue.Remove(11));
            d = datum.ToString("D");
            //Adding items to the listbox
            mittSchemaList.Add(new ItemViewModel() { Datum = d, Placering = itemValue.Remove(0, 15) });
        }
        mittSchemaListBox.ItemsSource = mittSchemaList;

    }
}
}

Here is the code that initiate the parse:-

    public void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        if (!App.ViewModel.IsDataLoaded)
        {
            App.ViewModel.LoadData();
        }
        MedinetWebRequest mittschema = new MedinetWebRequest();
        MedinetParsing mittparse = new MedinetParsing();
        mittschema.url = "https://medinet.se/cgi-bin/doctor.pl?action=login&customer=******&language=se";
        Action callback = () => Dispatcher.BeginInvoke(() => mittparse.parseResults(mittschema.myresponse));
        mittschema.getrequest(callback); 
    }

And lastly this is my Listbox:-

<ListBox Margin="0,0,-12,0" Name="mittSchemaListBox" DataContext="{Binding}" ItemsSource="{Binding Path=Items}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                            <!--Replace rectangle with image-->
                            <Canvas Height="100" Width="100" Margin="12,0,9,0" Background="#FFE5001B">
                                <TextBlock Text="{Binding Datum}" TextWrapping="Wrap" Height="100" Margin="0" HorizontalAlignment="Right" Width="100" />
                            </Canvas>
                            <StackPanel Width="311">
                                <TextBlock Text="{Binding Placering}" TextWrapping="Wrap" Margin="0,10" Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="36" TextAlignment="Center" FontWeight="Normal" />
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

Been trying to fix this issue for the last few hours and not getting anywhere, i decided to ask here. Hope someone can tell me what is the problem.

  • 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-04T03:04:42+00:00Added an answer on June 4, 2026 at 3:04 am

    Could not answer my question last night so here is the answer.

    Again after few hours getting back and forth with my code i just found out a solution that fits my app. The solution is that i changed this line of code in my MedinetParsing class

    mittSchemaList.Add(new ItemViewModel() { Datum = d, Placering = itemValue.Remove(0, 15) });
    

    with this one:-

    App.ViewModel.Items.Add(new ItemViewModel() {Datum=d,Placering=itemValue.Remove(0,15)}); 
    

    Got rid of this line of code:-

    mittSchemaListBox.ItemsSource = mittSchemaList;
    

    Now it is working like it should and i’m happy ;).
    Hope this will help someothers if they face such a problem.

    Yours

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

Sidebar

Related Questions

I have a custom-made view that extends the View class. I would like 2
I have made a custom Attribute here named AAtribute, and for instance a class
I've made an custom UILabel class in which i draw a red line at
I've made custom adapter and call notifyDataSetChanged() then data updates. But after call notifyDataSetChanged()
I made a custom control that is basically a multiline TextBox that allows input,
I made a custom class. This is the h file @interface Player : NSObject
I want to send class data through the Scala RemoteActor API. I made a
I made a movieclip in flash that dispatches a custom event: MyEvent.THE_TYPE = the_type
So i have made my own dict-based named-tuple class: class t(dict): def __getattr__(self, v):
I made a Validator that receives a class instance and a function name and

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.