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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:44:32+00:00 2026-05-30T15:44:32+00:00

I am working with mediaelement in wpf, but the problem is I can’t drop

  • 0

I am working with mediaelement in wpf, but the problem is I can’t drop media on medaiaelement.
can anyone tell me the solution.the following code is .cs file code. I set allow drop property= true

  private void mediaElement1_Drop(object sender, System.Windows.DragEventArgs e)
    {

        String[] FileName = (String[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop, true);
        if (FileName.Length > 0)
        {
            String VideoPath = FileName[0].ToString();
            mediaElement1.Source = new Uri(VideoPath);
            mediaElement1.Play();
        }
        e.Handled = true; 
    }
  • 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-30T15:44:33+00:00Added an answer on May 30, 2026 at 3:44 pm

    Tried it myself. Actually it will work after you play something there.
    Here’s the point: assume we have a Grid:

    <Grid AllowDrop="True"></Grid>
    

    It won’t allow drop.
    Now the following

    <Grid Background="Transparent" AllowDrop="True"></Grid>
    

    Will allow drop.

    The first Grid doesn’t have background at all, so actually there’s no way to drop anything on it – there’s no grid. And in second case there is grid’s background even though we can’t see it.

    The same thing applies to MediaElement. Unfortunately it doesn’t have any Background or Content property, so it won’t allow drop until you start playing something there.

    Solution is to handle drop on MediaElement parent container.

    By the way, don’t forget to set LoadedBehavior=”Manual” for MediaElement so that it will play dropped file.

    EDIT.

    Here is explanation why MediaElement doesn’t allow drop till any content was loaded in it.

    Every WPF component is in fact composed of some other basic elements: Borders, Grids, ContentPresenters etc. So something inside the MediaElement handles drop. I cannot tell you what element it is because MediaElement’s Template is not accessible. But it really doesn’t matter what exactly is the element that handles drag and drop there. What does matter is that there’s is nothing material in MediaElement’s area until you load content on it – just like in case of my example with Grid at the beginning of this post. I mean that when you move mouse cursor over it’s area there is nothing between cursor and MediaElement’s container. Try to handle MouseDown event: result will be the same – it won’t fire until you load any video. Why? Because there is nothing to raise event. Nothing cannot raise anything.
    As I mentioned before there is great difference between Background=”{x:Null}” and Background=”Transparent”: in first case there’s no background brush, no background, but in second case there is one. Feel the difference.

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

Sidebar

Related Questions

Working with Json, how can I NSlog only the title in this code: NSDictionary
I have some simple WPF with a MediaElement which is, generally, working. I have
I am using media element to render video in WPF. All videos are working
I'm working on a Windows Phone application that displays an audioStream (as radio) but
I'm working on a WPF application that displays video clips as part of the
Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies
I have a winforms form in which I use a MediaElement. Everything is working
I jave a strange issue, I'am using the mediaelement js media player to serve
I know I'm probably just going something wrong, but I can't figure it out
I need to display some media in a WPF project. The media could be

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.