스택 패널에서 런타임에 코드 뒤에 레이블을 추가합니다. 스택 패널을 스크롤 가능하게 만들고 싶습니다. xaml 파일에는 다음이 있습니다.
<ScrollViewer HorizontalAlignment="Left" Height="299" Margin="592,120,0,0" VerticalAlignment="Top" Width="188" VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="stackPanelVistaProfiloTessera" Height="292" Width="170"/>
</ScrollViewer>
뒤에있는 코드에서 스택 패널에 레이블을 추가합니다.
for(.....)
{
stackPanelVistaProfiloTessera.Children.Add(new Label {....});
}
스택 패널을 스크롤 할 수없는 이유는 무엇입니까? 이 문제를 어떻게 해결할 수 있습니까?
감사
stackpanel..rest에서 높이와 너비를 제거하면 여기에서 잘 작동합니다.
<ScrollViewer HorizontalAlignment="Left" Background="Green" Height="299" Margin="592,120,0,0" VerticalAlignment="Top" Width="188" VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="stackPanelVistaProfiloTessera" Background="RoyalBlue" >
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
<Label Height="30" Width="100" Margin="5">label1</Label>
</StackPanel>
</ScrollViewer>
출력은 다음과 같습니다.
디자인 목적으로 높이와 너비를 사용하는 경우 여백을 스택 패널로 설정할 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다