【发布时间】:2010-11-27 15:01:31
【问题描述】:
我认为这可能是一个简单的问题,但在搜索网络或 SO 时没有找到任何明确的答案。
我创建了一个ScrollBar 样式(使用标准滚动条模板 - Blend 2)
我不确定如何将此样式“MyScrollStyle”应用于ListBox 模板。
我在ListBox 模板上看到他们有一个ScrollViewer --> 应该包含ScrollBar。
假设它很简单:
<Setter Property ="Template" value="{Static Resource MyScrollStyle}"/>
---添加内容---
在模板编辑中经历了很多 xaml 之后,我有点理解如何应用样式。我正在尝试将此示例中设置的滚动视图样式 -http://blog.xamltemplates.net/wp-content/uploads/2008/12/scrollviewer.zip 添加到我的列表视图模板中,但它给出了以下错误:
System.Windows.Markup.XamlParseException was unhandled
Message="'ScrollViewer' object cannot be added to 'Border'. Exception has been thrown by the target of an invocation. Error at object 'System.Windows.Controls.ScrollViewer' in markup file 'MenuModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null;component/resources/Resources.xaml' Line 19 Position 26."
Source="PresentationFramework"
LineNumber=19
LinePosition=26
NameContext="1_T"
感谢任何帮助
谢谢你, 三月
【问题讨论】:
-
来自模板:
-
如果我错了,请纠正我:我必须为 ScrollViewer 编辑模板并在滚动查看器中使用 ScrollBar 样式。我应该将 ScrollViewer 样式应用于 ListBox