无法在scrollviewer中滚动

时间:2012-08-04 23:17:23

标签: silverlight xaml scrollview scrollviewer

当我添加titlepanel时,我失去了滚动的能力。请帮我恢复。

    <StackPanel>

            <Grid  HorizontalAlignment="Left">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <TextBlock .../>
            <TextBlock ... >
            </TextBlock>
        </Grid>
            <ScrollViewer  Grid.Row="1" x:Name="_ScrollViewer">
            <StackPanel  ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <Grid ScrollViewer.VerticalScrollBarVisibility="Disabled"> 
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <ListBox x:Name="listmy"
                                 Grid.Row="0" ScrollViewer.VerticalScrollBarVisibility="Disabled"
                                 >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <local:TypeMessage Content="{Binding}">
                                        <local:TypeMessage.Me>
                                            <DataTemplate>
                                                ...
                                            </DataTemplate>
                                        </local:TypeMessage.Me>
                                        <local:TypeMessage.Other>
                                            <DataTemplate>
                                                ...
                                            </DataTemplate>
                                        </local:TypeMessage.Other>
                                    </local:TypeMessage>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                        <Grid Grid.Row="3" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>
                            <tbox:WatermarkTextBox
                                                   ScrollViewer.VerticalScrollBarVisibility="Disabled"
                                                   />
                        </Grid>
                    </Grid>
                </StackPanel>
</ScrollViewer>
    </StackPanel>


</phone:PhoneApplicationPage>

1 个答案:

答案 0 :(得分:2)

问题发生在stackpanel中。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid Grid.Row="0" HorizontalAlignment="Left">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock  />
        <TextBlock  >
            <TextBlock.Foreground>
                <SolidColorBrush Color="{StaticResource PhoneContrastBackgroundColor}"/>
            </TextBlock.Foreground>
        </TextBlock>
    </Grid>
    <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Visible"  Grid.Row="1" x:Name="_ScrollViewer">
            <Grid ScrollViewer.VerticalScrollBarVisibility="Disabled"> 
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                <ListBox x:Name="listmy" ScrollViewer.VerticalScrollBarVisibility="Disabled"
                             Grid.Row="0">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <local:TypeMessage Content="{Binding}">
                                    <local:TypeMessage.Me>
                                     ...
                                    </local:TypeMessage.Me>
                                    <local:TypeMessage.Other>
                                    ...
                                    </local:TypeMessage.Other>
                                </local:TypeMessage>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                <StackPanel Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                    <tbox:WatermarkTextBox />
                </StackPanel>
            </Grid>