如何从wpf的后台代码中激发ViewModel中TextBlock的RoutedEvents。请让我知道,我可以如何在wpf代码后面绑定路由事件。谢谢
发布于 2011-09-27 01:37:46
好吧,我使用这个(你需要在Silverlight中使用System.Windows.Interactivity,但我怀疑它在WPF中是类似的):
xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
<TextBlock Text="{Binding InputValue, Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="GotFocus">
<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding InputValueGotFocusCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>您可以在Blend中轻松完成此操作
https://stackoverflow.com/questions/7496908
复制相似问题