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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:20:40+00:00 2026-05-30T22:20:40+00:00

I have three classes public class OSiteEquipment : IPlantItem public class OSiteSubSystem : IPlantItem

  • 0

I have three classes

public class OSiteEquipment : IPlantItem
public class OSiteSubSystem : IPlantItem
public class OSiteComponent : IPlantItem

Each implement interface IPlantItem

In my xaml i bind to an Observable collection like

public ObservableCollection<IPlantItem> CurrentItems

Sometimes i need to bind CurrentItems to an collection of OSiteEquipments and sometimes to OSiteSubSystem

If i try to set CurrentItems when i load the view like this

CurrentItems = this.siteDocument.Sitestructure.Equipments;

Where Sitestructure.Equipments is an observable collection of OSiteEquipment, compiler says i cant convert from Observablecollection<IPlantItem> to Observablecollection<OSiteEquipment>

Is there a way to solve this. DO i need to make an explicit conversion

EDIT

Solved it , instead of defining CurrentItems as ObservableCollection i as

object CurrentItems

The reason i didnt do it in the beginning was that i thougt i would destroy the notification binding, but it still works fine.

  • 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-30T22:20:41+00:00Added an answer on May 30, 2026 at 10:20 pm

    Explicit conversion from ObservableCollection<OSiteEquipment> to Observablecollection<IPlantItem> wouldn’t work either. If you wanted this to work, you would need to copy the elements of the OSiteEquipment collection to a new IPlantItem. But then changes to the original collection wouldn’t affect the new collection, so this is not what you want.

    You already found a solution, but I think it would be better if you changed the type of CurrentItems to IEnumerable<IPlantItem>. This shouldn’t affect the binding, but it means your code is safer and more self-documenting (it’s more obvious what should that property be).

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

Sidebar

Related Questions

Say I have the following three classes/interfaces: public interface IImportViewModel { } public class
I have three classes like this. class A { public class innerB { //Do
I have three classes public class User { public int Id { get; set;
I have three classes; Stamp, Letter and Parcel that implement an interface IProduct and
I have these three classes: Command: package pack; public abstract class Command impements java.io.Serializable
if I have these three classes: public class PropertyDouble { private double _value; public
I have three general repository that handle three base classes: public class Entity {
I have three classes public abstract class Champion { private String name; public Champion(String
I have three classes: public partial class Student : Contact { //Inherited from Contact:
Let's assume I have three classes that are subclasses of a base class: public

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.