I have created a MediaElement in XAML and assigned a .mpg as the source.
Looking at the XAML controls gallery from Microsoft, there are some examples such as:
<MediaPlayerElement Source="Assets/SampleMedia/fishes.wmv"
MaxWidth="400"
AutoPlay="True" />
However, I am faced with invalid markup that is returning:
The property AutoPlay was not found in type MediaElement
I have tried removing the AutoPlay and using a MediaOpened event to start the video from code behind,but there is never any trigger even?
I am not having too much success.
DO I need to add any additional resources to access certain properties?
<MediaElement x:Name="backdropMotion" Source="Images/inMotion_video.mpg"
Stretch="Fill" Margin="198,126,-326,229" Grid.Column="2"
LoadedBehavior="Play" IsEnabled="True" IsMuted="True"
Grid.Row="1" Grid.ColumnSpan="2" MediaOpened="MediaOpenedEvent"
AutoPlay="True"
>
Ultimately, I am trying to run a media element to a panel that effectively acts as an animated background, looping almost like a .gif. First step is to get the element running.
Related
How can I set Opacity of WebView2 control in WPF
I need to change opacity of WebView2 from 0 to 1 by using Storyboard but when I am trying to set "Opacity =0" to WebView2 it doesn't get apply.
So is there any way I can dynamically set its opacity?
WebView2 is not a native wpf control,it does not support transparency settings.
you can use CEFSharp,it provides the same feature of WebView2, and supports transparency settings.
NuGet\Install-Package CefSharp.Wpf -Version 108.4.130
It's simply impossible. WebView2 is HwndHost. it means they are native win32 windows placed exactly in location of specified in your WPF. So It's not a WPF element you can manipulate.
If you want to somehow hide the WebView for a while, you can use Visibility.
<wv2:WebView2 Visibility="Hidden" MinHeight="300" />
Above that control you can show a loading icon or something and animate it, not the WebView itself.
<Grid>
<wv2:WebView2 Visibility="Hidden" Width="500" Height="500" />
<custom:MyFancyLoadingControl Visibility="Visible" Width="500" Height="500" />
</Grid>
We are trying to switch our application from code behind coding to MVVM pattern.
We have a MediaElement in our XAML file :
<MediaElement Name="MyMedia" LoadedBehavior="Manual" UnloadedBehavior="Manual" MediaEnded="MediaEnd" MediaOpened="MediaBegin" Margin="10,24,13.6,10" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Visibility="Visible" />
For the moment, with the code behind coding approach, we can access the MediaElement directly in the .xaml.cs file to call methods like MediaElement.play() or MediaElement.pause().
The problem is that we are currently blocked when we try to convert our code to MVVM, because we can't access the MediaElement in the .cs file.
We are trying to bind the MediaElement itself so that we can call play or pause methods, but we haven't succeeded yet.
Any ideas ?
Thank you in advance.
This link describes how to control it http://msdn.microsoft.com/en-us/library/ms748248.aspx
it uses an event but still calls the MediaElement.play() in the event handler.
I'm attempting to place a Winforms panel within my WPF UserControl, with the following code;
<WindowsFormsHost Grid.Row="3">
<WinForms:Panel>
<WinForms:TableLayoutPanel x:Name="myLayoutPanel" />
</WinForms:Panel>
</WindowsFormsHost>
Error:
The type 'Panel' does not support direct content.
I'm will then then initialise the TableLayoutPanel panel within C# code. Any ideas how I can workaround this error?
the Windows.Forms Panel Container is called Controls. You should be able to add it by doing something like this: If it were me I would just create a Winforms UserControl and add that to the WinFormsHost instead.
<WindowsFormsHost Height="100" HorizontalAlignment="Left" Margin="10,108,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="200">
<WinForms:Panel BackColor="Red" Dock="Fill">
<WinForms:Panel.Controls>
<WinForms:TableLayoutPanel x:Name="myLayoutPanel"/>
</WinForms:Panel.Controls>
</WinForms:Panel>
</WindowsFormsHost>
Below is the XAML code i have for a Bing Maps Silverlight weather related implementation.
Here is what i am trying to do:
Have a bing maps with several (over 100) pushpins- on mouseover - show a contentpopup (canvas=myPopup) below. Simple enough.
Everything works fine - however, when mypopup displays on mouseover, it is not on the foreground (the other pins appear on top of the contentpopup) - hence making it not very readable.
Question:
How do i specifiy the myPopup canvas specified in XAML below to always appear in the foreground, i.e. top most of the Bing Maps silverlight control when a user views it on mouseover.
Thanks!
<Grid x:Name="LayoutRoot" Background="White">
<m:Map x:Name="GlobalMap" Mode="Road" Center="15,7" ZoomLevel="2" CredentialsProvider="{StaticResource MyCredentials}" Margin="-70,-40,-100,-72">
<m:MapLayer x:Name="myLayer">
<Canvas x:Name="myPopup" Visibility="Collapsed" Opacity="1">
<Rectangle x:Name="myPopupRectangle" Fill="White" Canvas.Left="0" Canvas.Top="0" Height="100"
Width="100" RadiusX="15" RadiusY="15"/>
<StackPanel Canvas.Left="8" Canvas.Top="8">
<TextBlock x:Name="myPopupTexts" FontSize="5" Width="100">
</TextBlock>
</StackPanel>
</Canvas>
</m:MapLayer>
</m:Map>
</Grid>
Try adding Canvas.ZIndex to the MapLayer element, give it a large value like 200 or add your push pins to another MapLayer (rather than adding the pins directly to the map) that appears ahead of this popup layer in document order.
I did something similar to this, but took a different approach. What I did was create a custom pushpin template and create a PopUp within the template.
When the user hovers over the pushpin, the popup is displayed. Using the PopUp will solve your problem, since the control will automatically position it on top of everything. Try wrapping the Canvas in a PopPup and see if that works.
hth
I'm working on an interactive map. I'm using Silverlight 4 within VisualStudio 2010.
My problem is that I can't assign a geometry to Button Clip property:
Code:
bouton1.Clip = (PathGeometry)Forme.Data;
//forme is a class that inherits from Path
when I run my application I get an ArgumentException:
The value is not included in the expected range
Your Path called "Forme" has its geometry defined using the Path Mini-Language right?
This type of Geometry cannot be share by multiple elements.
The work-around is store the path data as a string in a ResourceDictionary accessible to both your "Forme" element and "bouton1" then assign it using StaticResource. Something like:-
<StackPanel>
<StackPanel.Resources>
<sys:String x:Key="MyPath">M 10,100 C 10,300 300,-200 300,100</sys:String>
</StackPanel.Resources>
<Button x:Name="btn" Content="Button" Height="150" Clip="{StaticResource MyPath}" />
<Path Data="{StaticResource MyPath}" Stroke="Black" StrokeThickness="2" />
</StackPanel>
The painful downside is that the VS2010 designer doesn't grasp this and therefore doesn't apply the path. You would need to run the app to visually see the results.
I changed button with Path and MouseLeftButtonDown event, it works :)