【发布时间】:2011-07-01 13:24:37
【问题描述】:
wpf 中有一个命令属性,我试图在单击图像时执行它。我基本上是在改变滚动条的风格。我从here 下载了示例样式,在更改了我的样式后,我得到了类似的结果:
好的,让我解释一下。在顶部,图像顶部有一个向上的箭头。我计划摆脱顶部箭头,但我需要它的原因是因为在 xaml 中它有一个命令,当单击它时它会向上滚动。向上箭头的代码是:
<RepeatButton
Style="{StaticResource ScrollBarButton}"
Margin="0,15,0,0"
VerticalAlignment="Top"
Background="#FFFFFFFF"
Grid.Row="0"
Command="{x:Static ScrollBar.LineUpCommand}" <!-- This is the line that enables to scroll upwards when clicked -->
theme:ScrollChrome.ScrollGlyph="UpArrow"
RenderTransformOrigin="0.5, 0.5">
<RepeatButton.RenderTransform>
<ScaleTransform ScaleX="4" ScaleY="2"/>
</RepeatButton.RenderTransform>
</RepeatButton>
简而言之,我对以下属性感兴趣:
Command="{x:Static ScrollBar.LineUpCommand}"
如果我可以摆脱顶部箭头并将该命令放置在图像中,那就太好了。问题是图像控件没有属性命令。我知道我可以使顶部箭头的 alpha 等于 0 并使它看起来好像只有一个图像,但我很好奇了解它是如何工作的,而且我想添加更多功能,例如更改图像外观鼠标输入等等。
【问题讨论】:
标签: wpf xaml resources triggers styles