i am trying to run a .swf file in my WPF application, i have created a html page and in that i have referenced my .swf file using object tag and then loading that html page in my Main Window
my xaml looks like
<Window x:Class="sirajflash.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WebBrowser Name="myBrowser"></WebBrowser>
<!--<Frame Name="myframe"/>--> //tried with frame also but no luck
</Grid>
</Window>
assigning the source
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
myBrowser.Source = new Uri(CreateAbsolutePathTo("playflash.htm"), UriKind.Absolute);
}
private static string CreateAbsolutePathTo(string mediaFile)
{
return System.IO.Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, mediaFile);
}
}
The Problem:
when i run the application the warning occurs that ActiveX content is trying to access etc etc and when i allow it nothing appears in my main window the warning keeps on occuring multiple times.
if i run the flash movie in the browser directly it runs just fine.
Regards.
I have a flash based clock as a .swf file on my C:\Test\MyClock.swf
I have a htm file at C:\Test\MyHtml.htm
<embed src=C:\Test\MyClock.swf
width=200 height=200
wmode=transparent type=application/x-shockwave-flash>
</embed>
I have web browser control as below...
<Window x:Class="MyFlashApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WebBrowser Source="C:\Test\MyHtml.htm"></WebBrowser>
</Grid>
</Window>
On running the app, I see the webbrowser control giving warning as "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options."
I accept the warning by right click and the left click "Allow Blocked Content". A confirmation popup appears to which I say Yes.
I see the Flash based clock.
WebBrowser control can support flash directly . If you don't need to present anything in HTML then you can directly provide the path to the flash file .
myWebBrowser.Source = "C:\Test\MyClock.swf"
However you will still get the IE warning message.
Related
When I join a meeting on skype or teams I need to share the content of the application main window (without any other thing on the screen), but it's not showing in the window share menu, I can only stream it with the whole desktop.
see image here
But, when I open Login window it appears in the window share menu while the main window still do not appear ! As in the image below.
Login window appears in the menu
Does anyone have any idea what would prevent the window from appearing in the window share menu ?
I had the same problem and I figured out that the window needs a Title so it is selectable in Teams for sharing.
Once I added the Title to my main window everything works.
It can be done in the code:
mainWindow.Title = "test";
or in XAML:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Height="900" Width="1200" MinWidth="900"
x:Name="mainWindow"
Title="{x:Static p:Resource.MainView_Header}">
...
</Window>
I am working on webview control in C# UWP app. Everything was working. All at a sudden webview stop showing the webpage on the window. I tried creating one more app and rewrite the code once more. But it's not working now.
Below is the code.
<Page
x:Class="hello.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:hello"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid >
<WebView x:Name="webView" Source="http://www.www.bing.com" />
</Grid>
</Page>
ERROR :
I tried using other URLs as well. Tried webView.Navigate(new Uri("http://www.bing.com")); in the cs file as well , but webview is not at all appearing in the window. Searched a lot but did not get any solution.
All break points are getting hit properly and it's not throwing any error while running. Cleaned the debug folder manually and rebuild the app again .. but no luck.
Can someone help me to fix the issue ?
C# UWP WebView Not appearing on UWP mainpage
I checked your code, I found you have passed wrong uri http://www.www.bing.com, and if you want to make the webview fill the Grid you need set VerticalAlignment="Stretch" HorizontalAlignment="Stretch", I edited your code, and it works, please refer the following.
<Grid>
<WebView
x:Name="webView"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Source="http://www.bing.com"
/>
</Grid>
You could call webView.Navigate(new Uri("http://www.bing.com")) method in the page Loaded event, and remove above Source property in xaml code.
private void Page_Loaded(object sender, RoutedEventArgs e)
{
webView.Navigate(new Uri("http://www.bing.com"));
}
Please note your WebView will access internet, so you need check internet capability.
Thanks very much , Internet was the root cause , adding that solved the problem.
I have a fully functioning C# WPF application, which allows users to view PDF files from inside the application (File -> Load -> Select PDF).
I am also working on another C# WPF application, which has several different features, and I am displaying each of the features to the user on a separate tab using a <TabControl>
I would like to add the PDF Viewer capability to this second application, inside a new tab- I know that I could just copy over the source for the PDF Viewer manually into a new <TabItem> inside my second application, but what I am wondering is if there is a 'tidier' way of doing this, by creating an instance of my PDF Viewer application, and displaying that inside a new tab in my second application?
Is it possible to create an instance of one application from inside another? How would I do this if so?
What you can do is create a WPF user control library project(WpfControlLibrary1) , Move all of your PDF user code to that project and use the user control (UserControl1) in both projects either in code
as
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Content = new WpfControlLibrary1.UserControl1();
}
}
or in XAML you can use
<Window x:Class="WpfCustomControlLibrary1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<lib:UserControl1 />
</Grid>
</Window>
and thank you. I'm using Visual Studio 2015 and trying to navigate between 2 pages, MainPage.xaml and Meds.xaml On MainPage.xaml I put this button to navigate to Meds.xaml with.
<Button x:Name="button_meds" Content="Meds" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="268,405,0,0" FontSize="18.667" Click="button_meds_Click"/>
In the MainPage.xaml.cs file, I simply did this
private void button_meds_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(Meds));
}
Meds.xaml has an image and background, but I omitted the logo and grid from the code below
<Page
x:Class="SQLMobileMoodSwing.Meds"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SQLMobileMoodSwing"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
</Page>
I'm not getting any errors, but when I click the button, it simply takes me to a white page. Not sure what I'm doing wrong, have looked for solutions but nothing seems to work.
Thank you!
I have created Meds.xaml as XAML View, not as Blank Page.
Then I deleted it and created again as a Blank Page and BOOM! It works
There is currently not an available WPF viewer for Active Reports 6. I was attempting to use a host control to display the viewer in a interop host but I'm not having much luck. Has anyone else attempted this successfully? I can't even get the wrapper Viewer control to add to the project toolbox as a custom control at this point. I'm hoping to avoid recreating the wheel.
The existing ActiveReports Viewer works fine in WPF. You can use the below XAML to host it in WPF:
<Window x:Class="ARViewerHostedInWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:arv="clr-namespace:DataDynamics.ActiveReports.Viewer;assembly=ActiveReports.Viewer6"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<WindowsFormsHost Name="windowsFormsHost1">
<arv:Viewer x:Name="ARViewer" Dock="Fill" />
</WindowsFormsHost>
</Grid>
</Window>
The following code in the code-behind of the XAML file will connect a report to the viewer in the XAML above and run it:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
NewActiveReport1 rpt = new NewActiveReport1();
this.ARViewer.Document = rpt.Document;
rpt.Run();
}
}
I'm using the currently available version of ActiveReports 6 to test this.
Hope this helps!
Scott Willeke
GrapeCity