积极答复者
请问如何为WPF自定义面板添加滚动条

问题
答案
-
你好,
我想你可以这样来操作,在XAML代码中添加自定义的Panel,然后按照我给的第一段代码增加滚动条。
例如:C#代码:
public class CustomPanel: Panel { //... }
XAML代码:
<Window x:Class="CustomPanelScrollViewerApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustomPanelScrollViewerApp" Title="MainWindow" Height="150" Width="525"> <ScrollViewer VerticalScrollBarVisibility="Auto"> <local:CustomPanel> <!--.....--> </local:CustomPanel> </ScrollViewer> </Window>
这里有两个类似帖子,建议参考下:
http://stackoverflow.com/questions/3978839/problem-with-custom-scrolling-in-custom-panel
另外如果这些内容都不能帮助到你,建议贴出关于这个自定义Panel的代码,这样也便于分析问题。
谢谢!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已编辑 Leo (Apple) YangModerator 2014年4月23日 8:17 Edit
- 已标记为答案 ZQing 2014年4月23日 8:36
全部回复
-
你好,
一般情况下,可以这样添加:
<CustomPanel> <ScrollViewer VerticalScrollBarVisibility="Auto"> <StackPanel /> </ScrollViewer > </CustomPanel>
如果不可以,建议贴一下你的自定义Panel代码。
谢谢!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
你好,
我想你可以这样来操作,在XAML代码中添加自定义的Panel,然后按照我给的第一段代码增加滚动条。
例如:C#代码:
public class CustomPanel: Panel { //... }
XAML代码:
<Window x:Class="CustomPanelScrollViewerApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustomPanelScrollViewerApp" Title="MainWindow" Height="150" Width="525"> <ScrollViewer VerticalScrollBarVisibility="Auto"> <local:CustomPanel> <!--.....--> </local:CustomPanel> </ScrollViewer> </Window>
这里有两个类似帖子,建议参考下:
http://stackoverflow.com/questions/3978839/problem-with-custom-scrolling-in-custom-panel
另外如果这些内容都不能帮助到你,建议贴出关于这个自定义Panel的代码,这样也便于分析问题。
谢谢!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已编辑 Leo (Apple) YangModerator 2014年4月23日 8:17 Edit
- 已标记为答案 ZQing 2014年4月23日 8:36