[英]Show a Powerpoint Presentation in a Frame in WPF
我試圖實現的是直接顯示PowerPoint演示文稿,而無需在WPF窗口中打開Powerpoint。 現在我正在使用此代碼啟動演示文稿:
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE";
proc.StartInfo.Arguments = " /s " + source.ToString();
proc.Start();
變量源是所需文件的路徑。 此代碼以全屏模式打開PowerPoint演示文稿,這很好,但我的應用程序在沒有連接鍵盤或鼠標的觸摸設備上運行。 所以我希望能夠在演示文稿本身上方放置一個覆蓋圖,例如“Close”-Button。
我已經在WPF窗口中找到了這個主題托管外部應用程序 ,但我很難理解實際上在那里發生了什么。
我希望有一個人可以幫助我。
提前致謝。
我設法以一種我很舒服的方式做到了。 這是代碼:
XAML:
<Window x:Name="window" x:Class="Project.PowerPointViewer"
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"
xmlns:local="clr-namespace:Project"
mc:Ignorable="d"
Title="PowerPointViewer" Background="Transparent" Topmost="True" AllowsTransparency="True" ResizeMode="NoResize" WindowStyle="None" WindowState="Maximized">
重要的部分是:Background,Topmost和AllowTransparency
代碼背后:
public partial class PowerPointViewer : Window
{
Process proc = new Process();
Window main;
public PowerPointViewer(Window main)
{
InitializeComponent();
this.main = main;
}
public void open(string source)
{
proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE";
proc.StartInfo.Arguments = " /s " + source;
proc.Start();
Show();
}
private void bt_close_Click(object sender, RoutedEventArgs e)
{
if (!proc.HasExited)
proc.Kill();
Close();
main.Focus();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.