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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:02:54+00:00 2026-06-17T16:02:54+00:00

I have wfp form like that: public partial class MediaPlayerControlMain : Window { MediaPlayerMain

  • 0

I have wfp form like that:

public partial class MediaPlayerControlMain : Window
{
    MediaPlayerMain MediaPlayerMain;

    public MediaPlayerControlMain()
    {
        MediaPlayerMain = new MediaPlayerMain();
        InitializeComponent();
    }
}

I have my user control (PlayList) that use MediaPlayerMain object.
That User Control have that:

public partial class PlayList : UserControl
{
    public MediaPlayerMain MediaPlayer
    {
        get { return (MediaPlayerMain)GetValue(MediaPlayerProperty); }
        set { SetValue(MediaPlayerProperty, value); }
    }

    public static readonly DependencyProperty MediaPlayerProperty =
        DependencyProperty.Register(
            "MediaPlayer", typeof(MediaPlayerMain), typeof(PlayList),
            new FrameworkPropertyMetadata()
        );

}

Is there the way to set MediaPlayer property using just xaml. I tried to use “{Binding ElementName=MediaPlayerMain}” but it seems to be that MediaPlayerMain haven’t initialized yet. Although i initialized it before InitializeComponent() function. What am i doing wrong?. And what is the best option to pass this object to my user control?

  • 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-17T16:02:55+00:00Added an answer on June 17, 2026 at 4:02 pm
    public partial class MediaPlayerControlMain : Window,INotifyPropertyChanged
        {
    
    
            public MediaPlayerControlMain()
            {                
                InitializeComponent();
                MediaPlayerMain = new MediaPlayerMain();
            }
            private MediaPlayerMain mediaPlayerMain;
    
            public MediaPlayerMain MediaPlayerMain
            {
                get { return mediaPlayerMain; }
                set { mediaPlayerMain = value; Notify("MediaPlayerMain"); }
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            private void Notify(string propName)
            {
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs(propName));
    
            }
        }
    
     "{Binding MediaPlayerMain RelativeSource={RelativeSource AncestorType=Window}}"
    

    The issue is you are trying to bind the field not property.For binding source must be the property not field because binding system uses reflection and looks only for properties not for fields.I hope this will help.

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

Sidebar

Related Questions

Have have this line of code in my form when I create a new
have a class structure like so Permit -> Financial ->ICollection instrumentList Instrument -> Agency
Have a test program public class Path { public static void main(String[] args) {
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I'm new to WFP and try to learn it via different examples. Right now
Have got a method which returns IEnumerable<User> which I have been using Linq /
Have a chat room, issue is, is that when you submit something, the message
I have created a WFP UserControl with some complex XAML (converted from SVG). It's
Have a photography site that I want to prevent image copying from. How can

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.