听起来System.Windows.Interactivity
和Microsoft.Expression.Interactions
组合将非常适合您的需求。
在此示例中,我们使用System.Windows.Interactivity
EventTrigger
事件MediaElement
BufferingStarted
来更改属性并使用方法调用模型上的Microsoft.Expression.Interactions
方法
<Window x:Class="WpfApplication14.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"
xmlns:expint="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:sysint="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
<Grid>
<MediaElement >
<sysint:Interaction.Triggers>
<sysint:EventTrigger EventName="BufferingStarted" >
<expint:ChangePropertyAction PropertyName="MyProperty" Value="NeValue" />
<expint:CallMethodAction MethodName="MyModelMethod"/>
</sysint:EventTrigger>
</sysint:Interaction.Triggers>
</MediaElement>
</Grid>
</Window>
Yuo 将不得不添加对System.Windows.Interactivity
dllMicrosoft.Expression.Interactions
的引用。这Microsoft.Expression.Interactions
是ExpressionBlend SDK的一部分
希望这会有所帮助,因为我发现这个组合对于 WPF 开发来说非常棒。
快乐编码:)