내가 원하는 무엇 : 내가 내용과 함께 높이에서 자랍니다 내 실버 라이트 4 응용 프로그램에서있는 ScrollView을하고 싶은, 하지만 쇼를 않습니다 그렇지 않으면 스크롤 막대가 컨테이너보다 더 많이 자랄 수 있습니다.성장있는 ScrollView (높이 = "자동"MaxHeight입니다 = "스트레치")
솔루션은 내가 발견 솔루션이에서 ScrollViewer를 스트레치을 어디에 내가 묻는 질문을 많이 찾았지만 그게 내가 원하는 하지입니다. Scrollviewer는 항상 가능한 한 작아야합니다.
내 문제 : 스크롤 뷰어 위에 조금 더 어렵게 만들려면 정적 높이가있는 스택 패널 인 헤더가 있어야합니다.
솔루션 승인 1 : 먼저 일반 XAML로 시도했지만 작동 방법을 파악할 수 없습니다.
<Grid Height="Auto" x:Name="myGrid" >
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Background="AliceBlue">
<!-- Dummy Header-->
</StackPanel>
<ScrollViewer Grid.Row="1" Height="Auto">
<Button Width="100" Height="50" Click="Button_Click" />
<!-- onClick the button will switch between height="600" and height="50"
Code:
private void Button_Click(object sender, RoutedEventArgs e)
{
if (sender is Button)
{
Button btn = (Button)sender;
btn.Height = (btn.Height == 50) ? 600 : 50 ;
}
}
-->
</ScrollViewer>
</Grid>
버튼을 클릭하면 키가 커지기 때문에 버튼이 높아지면 스크롤바가 잘립니다. 어떤 설교?
해결 접근 2 : 그러면 I은 주위의 ScrollViewer * 최대 * 포함하는 컨테이너의 ActualHeight와의 ScrollViewer의 높이, 따라서 I는 inseted StackPanel에 설정하려고. VS2010 XAML 디자이너에서는 작동하지만 코드 실행에서는 작동하지 않습니다. 나는 아무런 단서가 없다 ...
<Grid Height="Auto" x:Name="myGrid" >
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Background="AliceBlue">
<!-- Dummy Header-->
</StackPanel>
<StackPanel Grid.Row="1" x:Name="myStackPanel" Height="Auto" VerticalAlignment="Stretch">
<ScrollViewer Height="Auto" MaxHeight="{Binding ElementName=myStackPanel, Path=ActualHeight}">
<Button Width="100" Height="50" Click="Button_Click" />
<!-- onClick the button will switch between height="600" and height="50"
Code:
private void Button_Click(object sender, RoutedEventArgs e)
{
if (sender is Button)
{
Button btn = (Button)sender;
btn.Height = (btn.Height == 50) ? 600 : 50 ;
}
}
-->
</ScrollViewer>
</StackPanel>
</Grid>
미리 감사드립니다!
잘 작동합니다. 그리고 당신의 설명은 내게 총을 의미합니다! 고마워요! – heynest