小编H4m*_*ead的帖子

WPF,如何确定MediaElement何时播放完电影?

我正在我的应用程序上显示一部电影,我希望应用程序只播放一次.当它完成播放时我想启用一些按钮(播放,倒带,再次观看等等)但是有什么方法可以在电影结束时获得一个事件 - 或任何可以完成这个场景的事情?

干杯,

wpf mediaelement

9
推荐指数
1
解决办法
6910
查看次数

以WPF控件为中心

我有一个窗口,我添加一个新UserControl的(带图像),我只想将控件置于屏幕中间(垂直和水平).我只能让垂直的工作.我将在DockPanel我的CodeBehind中交换内容,并希望在我开始播放幻灯片UI之前显示此启动屏幕,这意味着内容是从CodeBehind设置的.

我的Window:

<Window x:Class="GreenWebPlayerWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="512" Width="853" WindowStyle="None" WindowState="Maximized" WindowStartupLocation="CenterScreen">
    <DockPanel Width="Auto" Height="Auto" Name="TransitionContainer" Background="Black" Margin="0" LastChildFill="True"></DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

我的UserControl:

<UserControl x:Class="GreenWebPlayerWPF.FrontPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <DockPanel Background="Black">
        <Image Name="image1" Stretch="None" Source="/GreenWebPlayerWPF;component/gw.png" />
    </DockPanel>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

请注意,我使用的是最大化/全屏.

wpf layout fill

7
推荐指数
1
解决办法
1万
查看次数

Flowdocument 未使用完整宽度/高度

我有一个 FlowDocument,我想填充窗口的整个宽度和高度。我尝试过使用FlowDocumentPageViewer(没有运气),现在正在使用DocumentPageView. 我仍然无法让它停靠/填满整个空间;它只是坐在中间,以它可以创建的最小尺寸(这有意义吗?)

这是我的代码:

   public DocumentPageView GetPage()
   {
        FlowDocumentPageViewer viewer = new FlowDocumentPageViewer();           
        StreamReader reader = new StreamReader(location);
        string data = reader.ReadToEnd();
        reader.Close();
        string xamlData = HtmlToXamlConverter.ConvertHtmlToXaml(data, true);
        FlowDocument result = (FlowDocument)System.Windows.Markup.XamlReader.Load(new MemoryStream(System.Text.UnicodeEncoding.Default.GetBytes(xamlData)));

        viewer.Document = result;
        viewer.VerticalAlignment = VerticalAlignment.Center;
        viewer.HorizontalAlignment = HorizontalAlignment.Center;

        DocumentPageView pageView = new DocumentPageView();
        pageView.VerticalAlignment = VerticalAlignment.Center;
        pageView.HorizontalAlignment = HorizontalAlignment.Center;
        pageView.Stretch = System.Windows.Media.Stretch.Uniform;
        pageView.PageNumber = 0;
        pageView.StretchDirection = StretchDirection.Both;
        pageView.DocumentPaginator = ((IDocumentPaginatorSource)result).DocumentPaginator;
        return pageView;
   }
Run Code Online (Sandbox Code Playgroud)

请注意,此代码包含我的两种方法的组合,但DocumentPageView当前仅使用。这是从我的 HTML 源创建的 Xaml:

<FlowDocument xml:space="preserve" …
Run Code Online (Sandbox Code Playgroud)

wpf resize flowdocument

3
推荐指数
1
解决办法
8973
查看次数

Silverlight交叉线程ui更新问题

我有这门课:

public class UploadFile : INotifyPropertyChanged {
    private string name;
    public string Name {
        get {
            return name;
        }
        set {
            name = value;
            OnPropertyChanged("Name");
        } 
    }

    private FileInfo fileInfo;
    public FileInfo FileInfo { get; set; }

    private string length;
    public string Length {
        get {
            return length;
        }
        set {
            length = value;
            OnPropertyChanged("Length");
        }  
    }

    private int percentage;
    public int Percentage {
        get {
            return percentage;
        }
        set {
            percentage = value;
            OnPropertyChanged("Percentage");
        } 
    }

    public string ProgressValue …
Run Code Online (Sandbox Code Playgroud)

silverlight multithreading

3
推荐指数
1
解决办法
1989
查看次数

如何在实例化对象上使用反射调用方法?

我有一些基础对象"Car","dog","cat"他们实现了一个接口"IGWUIElement".我有一个这些接口的列表:列出myList.

在运行时,我循环遍历我的元素列表,并通过检查类的名称(使用反射)我需要填充它们的属性 - 这不是界面的一部分).我有一个xml文档描述了我应该分配给它们的属性和值.这是我的界面实例化.

IGWUIElement newUIElement = (IGWUIElement)Activator.CreateInstance(result);
Run Code Online (Sandbox Code Playgroud)

如何使用特定值从名称中调用属性(请注意,数据类型仅限于int和string).每个对象都有不同的属性.

希望这有道理......

/ H4mm3r

c# reflection

1
推荐指数
1
解决办法
554
查看次数