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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:48:40+00:00 2026-06-07T03:48:40+00:00

I have a taskbar-application developed with WPF, where I just can’t figure out how

  • 0

I have a taskbar-application developed with WPF, where I just can’t figure out how to bind my collection of objects with Objectbinding to a TrayPopUp.

Here’s my collection class. It is created on startup and filled with objects by deserializing a xmlfile (with fillCollectionFromXml-method):

public class OrdreCollection
{
    // Fields
    private ObservableCollection<Ordre> _ordreList = new ObservableCollection<Ordre>();


    // Properties
    public ObservableCollection<Ordre> OrdreList
    {
        get
        {
            if (_ordreList == null)
            {
                return new ObservableCollection<Ordre>();
            }
            return _ordreList;
        }

        set
        {
            _ordreList = value;
        }
    }


    //Methods

    public void fillCollectionFromXml(String filepath)
    {            
        XmlSerializer xs = new XmlSerializer(typeof(ObservableCollection<Ordre>));
        using (StreamReader rd = new StreamReader(filepath))
        {
            OrdreList = xs.Deserialize(rd) as ObservableCollection<Ordre>;
        }
    }

    public void createXmlFromCollection(OrdreCollection oCol, String filepath)
    {
        XmlSerializer xs = new XmlSerializer(typeof(ObservableCollection<Ordre>));
        using (StreamWriter wr = new StreamWriter(filepath))
        {
            xs.Serialize(wr, OrdreList);
        }
    }

    //public OrdreCollection getOrdrer(String filepath)
    //{
    //    OrdreCollection Ordrer = new OrdreCollection();
    //    Ordrer.fillCollectionFromXml("@../../Data/Ordrer.xml");

    //    return Ordrer;
    //}
}
}

Base-classes:

[Serializable]
public class Ordre : INotifyPropertyChanged
{
    // INotifyPropertyChanged Member
    public event PropertyChangedEventHandler PropertyChanged;
    void Notify(string propName) {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propName));
    }

    // Fields
    private DateTime ordreDato = DateTime.Today;
    private int ordreReference = 561978;
    private String bestiltAf;
    private List<OrdreItem> ordreItem;

    //Constructors

    public Ordre() { }

    public Ordre(DateTime ordredato, int ordrereference, String bestiltAf, List<OrdreItem> ordreItem)
    {
        this.Ordredato = ordredato;
        this.Ordrereference = ordrereference;
        this.BestiltAf = bestiltAf;
        this.OrdreItem = ordreItem;
    }


    //Properties

    public DateTime Ordredato
    {
        get { return ordreDato; }
        set { 
            ordreDato = value;
            Notify("OrdreDato");
        }
    }

    public int Ordrereference
    {
        get { return ordreReference; }
        set { 
            ordreReference = value;
            Notify("Ordrereference");
        }
    }

    public String BestiltAf
    {
        get { return bestiltAf; }
        set { 
            bestiltAf = value;
            Notify("BestiltAf");
        }
    }

    public List<OrdreItem> OrdreItem
    {
        get { return ordreItem; }
        set {
            ordreItem = value;
            Notify("OrdreItem");
        }
    }


    //Methods

    public void addItem(OrdreItem item)
    {
        OrdreItem.Add(item);
    }
}

[Serializable]
public class OrdreItem : INotifyPropertyChanged
{
    // INotifyPropertyChanged Member
    public event PropertyChangedEventHandler PropertyChanged;
    void Notify(string propName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propName));
    }

    // Fields
    private String produktKode;
    private String produktNavn;
    private DateTime kalibreringsDato;
    private DateTime leveringsDato;
    private int antal;

    // Constructors
    public OrdreItem() { }
    public OrdreItem(String produktKode, String produktNavn, DateTime kalibreringsDato, DateTime leveringsDato, int antal)
    {
        this.produktKode = produktKode;
        this.produktNavn = produktNavn;
        this.kalibreringsDato = kalibreringsDato;
        this.leveringsDato = leveringsDato;
        this.antal = antal;
    }

    //Properties
    public String ProduktKode
    {
        get { return produktKode; }
        set {
            produktKode = value;
            Notify("ProduktKode");
        }
    }

    public String ProduktNavn
    {
        get { return produktNavn; }
        set {
            produktNavn = value;
            Notify("ProduktNavn");
        }
    }

    public DateTime KalibreringsDato
    {
        get { return kalibreringsDato; }
        set { 
            kalibreringsDato = value;
            Notify("KalibreringsDato");
        }
    }

    public DateTime LeveringsDato
    {
        get { return leveringsDato; }
        set { 
            leveringsDato = value;
            Notify("LeveringsDato");
        }
    }

    public int Antal
    {
        get { return antal; }
        set {
            antal = value;
            Notify("Antal");
        }
    }
}

Here’s my XAML:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:tb="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
                    xmlns:local="clr-namespace:WpfApplication1.Models"
                    x:Class="WpfApplication1.Resources"
                    x:ClassModifier="public"
                    >
    <!-- Globaly declared OrdreCollection. Contains a list of orders.-->
    <local:OrdreCollection x:Key="OrdreList"></local:OrdreCollection>

    <!-- Globally declared notify icon -->
    <tb:TaskbarIcon x:Key="MyNotifyIcon" 
                    IconSource="/Icons/ge256x256new.ico" 
                    ToolTipText="GE Ordre Management"
                    PopupActivation="LeftOrDoubleClick"
                    DataContext=" "
                    >
    <!--
    We can use arbitrary UI elements as ToolTips.
    Let's use a semi-transparent border.
    -->

        <!-- Set a simple popup  -->
        <tb:TaskbarIcon.TrayPopup>
            <Border
                Background="White"
                BorderBrush="Orange"
                BorderThickness="2"
                CornerRadius="4" Margin="0" Padding="10">
                <GroupBox Header="Bestillinger" Height="Auto" Name="BestillingGroupBox" Width="445" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="10">
                    <Grid>
                        <!--<ListBox ItemsSource="{Binding}" DisplayMemberPath="ordreDato"/>-->
                        <ListView IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding OrdreList}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Header="Ordredato" DisplayMemberBinding="{Binding Path=Ordredato}" />
                                    <GridViewColumn Header="Navn" DisplayMemberBinding="{Binding Path=BestiltAf}" />
                                    <GridViewColumn Header="Ordrenummer" DisplayMemberBinding="{Binding Path=Ordrereference}" />
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </Grid>
                    <!--<Grid>
                        <Grid.DataContext>
                            <XmlDataProvider Source="@../../Data/employees.xml" />
                        </Grid.DataContext>
                        <Grid.Resources>
                            <HierarchicalDataTemplate x:Key="OrdreTemplate" DataType="Ordre">
                                <Border Background="White" BorderBrush="Orange" BorderThickness="2" CornerRadius="4" Margin="0" Padding="10" Width="400">
                                <TextBlock>
                                <TextBlock FontWeight="bold">Antal: </TextBlock>
                                <TextBlock Text="{Binding XPath=Antal}" />
                                <TextBlock FontWeight="bold">Produkt: </TextBlock>
                                <TextBlock Text="{Binding XPath=Produkt}" />
                                <LineBreak></LineBreak>
                                <TextBlock FontWeight="bold">Dato:</TextBlock>
                                <TextBlock Text="{Binding XPath=Dato}" />
                                <LineBreak></LineBreak>
                                <TextBlock FontWeight="bold">Bestilt af:</TextBlock>
                                <TextBlock Text="{Binding XPath=BestiltAf}" />
                                <LineBreak></LineBreak>
                                <TextBlock FontWeight="bold">Leveringsdato:</TextBlock>
                                <TextBlock Text="{Binding XPath=TilLevering}" />
                                <LineBreak></LineBreak>
                                <TextBlock FontWeight="bold">Ordrenr.:</TextBlock>
                                <TextBlock Text="{Binding XPath=OrdreNr}" />                            
                            </TextBlock>
                                </Border>
                            </HierarchicalDataTemplate>
                        </Grid.Resources>

                        <ListBox                         
                        Name="treeView" 
                        ItemsSource="{Binding Path=.,XPath=/Ordrer/Ordre}"
                        ItemTemplate="{StaticResource OrdreTemplate}" Background="white"
                        BorderBrush="Black"
                        BorderThickness="1"
                        Padding="4" />
                    </Grid>-->
                </GroupBox>
            </Border>
        </tb:TaskbarIcon.TrayPopup>
    </tb:TaskbarIcon>
</ResourceDictionary>

The problem is with TrayPopup. This I would like to show the values of all Orders in my OrderCollecion in a listview/listBox. I hope my question is understandable and that my code isn’t too messy. I can make it work when I fill a listbox with a XmlDataProvider, but not with a ObjectdataProvider or directly from a collection.

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

    Found the answer to my problem. Had to use a CollectionViewSource.

    <CollectionViewSource 
              Source="{Binding Source={x:Static Application.Current}, Path=OrdreItems}"   
              x:Key="ordreDataView" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF TaskBar like application that i am developing for fun and
I have a WPF application that sometimes cannot be restored from the taskbar. This
Update I have just tried Pinning my site to the Taskbar again (after removing
I have a WPF application where i show a dialog with nrDialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
I'm currently developing a WPF application in C# and I want to have a
I have the application using an .ico image for the taskbar and window, but
I have two forms for my application, that are visible in the Windows taskbar.
I have developed a javascript based widget application having IM features, use case of
How do I set an application's taskbar icon in PyQt4? I have tried setWindowIcon,
I have a Delphi application similar to Taskbar Shuffle that includes a hook dll.

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.