重置 TranslateZoomRotateBehavior? (WPF/混合行为)
我已将 TranslateZoomRotateBehavior 附加到网格:
<Grid>
<!--all sorts of content-->
<Button Content="Cancel" Click="CancelButton_Click Width="25" Height="20"/>
<i:Interaction.Behaviors>
<ei:TranslateZoomRotateBehavior ConstrainToParentBounds="True" SupportedGestures="Translate"/>
</i:Interaction.Behaviors>
</Grid>
在 CancelButton_Click 事件处理程序中,我想重置 TranslateZoomRotateBehavior 以返回网格及其内容到其原始位置。有谁知道这是否可能?
I have attached a TranslateZoomRotateBehavior to a Grid:
<Grid>
<!--all sorts of content-->
<Button Content="Cancel" Click="CancelButton_Click Width="25" Height="20"/>
<i:Interaction.Behaviors>
<ei:TranslateZoomRotateBehavior ConstrainToParentBounds="True" SupportedGestures="Translate"/>
</i:Interaction.Behaviors>
</Grid>
in the CancelButton_Click eventhandler I want to reset the TranslateZoomRotateBehavior to return the Grid and it's content to it's original position. Does anyone know whether this is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TranslateZoomRotateBehavior
正在将MatrixTransform
添加到它所附加的元素。因此修改您的示例:
然后您可以按以下方式在代码中重置它:
TranslateZoomRotateBehavior
is addingMatrixTransform
to element it is attached to.So modifying your example:
Then you can reset it in code the following way:
如果您指定要在其上重置行为集合的网格。
您可以在代码后面获取行为列表
,然后您可以随意使用它们,如果您想将它们全部删除,则可以使用 .Clear() 如果您只想重置值但保留您可以访问的 TranslateZoomRotateBehavior它与
If you name the grid that you want to reset the behaviours collection on.
You can get a list of the behaviors in code behind with
You're then free to work with them however you want, if you want to remove them all .Clear() if you want to reset just values but keep the TranslateZoomRotateBehavior you can access it with