前提・実現したいこと
Windows10 Homeで、Visual Studio 2017を使って、WPFアプリケーションを作っています。
StackPanelを縦スクロールしたいです。
発生している問題・エラーメッセージ
スクロールバーは出るが、スクロールのノブが出ないのでスクロールできない。
該当のソースコード
xaml
1<Window x:Class="WPFApplication.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:local="clr-namespace:WPFApplication" 7 mc:Ignorable="d" 8 Loaded="Window_Loaded" 9 Title="main" Width="725" > 10 <StackPanel> 11 <StackPanel Orientation="Horizontal"> 12 <TextBox x:Name="FolderPath" ></TextBox> 13 </StackPanel> 14 <ScrollViewer> 15 <StackPanel Name="MainIndex" /> 16 </ScrollViewer> 17 </StackPanel> 18</Window>
C#
1 private void Window_Loaded(object sender, RoutedEventArgs e) 2 { 3 var files= Directory.GetFiles(@"C:\tmp", "*.*"); 4 foreach (var file in files) 5 AddButton(file); 6 } 7 8 private void AddFolderButton(string file) 9 { 10 var button = new Button(); 11 button.Content = Path.GetFileName(file); 12 MainIndex.Children.Add(button); 13 }
Loadedで読んだ後に、なにか処理が必要ですか
補足情報(FW/ツールのバージョンなど)
Visual Studio 2017 Community
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/26 09:35