###前提・実現したいこと
WPFでScrollViewerを設置すると、隣接するオブジェクトに隙間ができる。
マージンを引くことで隙間は削除できるのですが、ビューと実行結果が異なるため、どうにか解決できないでしょうか…
###発生している問題・エラーメッセージ
XML
1<Window x:Class="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:Tw" 7 mc:Ignorable="d" 8 Title="MainWindow" Height="350" Width="525"> 9 <Grid> 10 <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0,0,0,133" Background="Aqua"> 11 12 </ScrollViewer> 13 <StackPanel Background="AliceBlue" Margin="0,186,0,0"> 14 15 </StackPanel> 16 </Grid> 17</Window> 18
上記コードの場合、ビューワ上は問題ないのですが、実行するとScrollViewerとStackpanelの間に空白ができます。
###追記
XML
1 2<Window x:Class="MainWindow" 3 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 4 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 5 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 6 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 7 xmlns:local="clr-namespace:Tw" 8 mc:Ignorable="d" 9 Title="MainWindow" Height="350" Width="525"> 10 <Grid> 11 12 <DockPanel> 13 <ScrollViewer VerticalScrollBarVisibility="Auto" Background="Aqua" Height="259" DockPanel.Dock="Top"> 14 15 </ScrollViewer> 16 <StackPanel Background="AliceBlue" Height="60" DockPanel.Dock="Bottom"> 17 <TextBox Height="40"></TextBox> 18 <Button Content="aaa"/> 19 </StackPanel> 20 21 </DockPanel> 22 23 </Grid> 24</Window>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/09 13:24
2017/02/11 14:38