框架中的 GridSplitter;超越边界问题

发布于 2024-12-05 01:27:22 字数 4900 浏览 1 评论 0原文

我有一个用于在 Silverlight RIA 应用程序中显示数据的通用视图。基本上,视图接受一个参数,该参数是 RIA 获取数据所需的查询,并且使用自动生成的字段显示数据。

以下是视图的 XAML 代码的一部分。

        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition x:Name="DataGridRow"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition x:Name="DataFormRow"/>
                <RowDefinition Height="Auto" x:Name="EditRow"/>
            </Grid.RowDefinitions>
            <ria:DomainDataSource Name="SQLDomainDataContext" LoadingData="SQLDomainDataContext_LoadingData" LoadSize="45" SubmittedChanges="SQLDomainDataContext_SubmittedChanges" SubmittingChanges="SQLDomainDataContext_SubmittingChanges" LoadedData="SQLDomainDataContext_LoadedData">
                <ria:DomainDataSource.SortDescriptors>
                    <ria:SortDescriptor Direction="Descending" PropertyPath="BaseProperties.CreatedOn" />
                </ria:DomainDataSource.SortDescriptors>
            </ria:DomainDataSource>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <sdk:DataGrid  Grid.Row="0" AutoGenerateColumns="True" Name="dataGrid" ItemsSource="{Binding}" DataContext="{Binding Path=Data, Mode=TwoWay}" IsReadOnly="True" AutoGeneratingColumn="dataGrid_AutoGeneratingColumn" SelectionChanged="dataGrid_SelectionChanged" />
                <custCont:LocalizedDataPager Grid.Row="1" x:Name="pager" Source="{Binding Path=Data}" PageSize="15" DisplayMode="FirstLastPreviousNext" />
            </Grid>

            <Border Grid.Row="1">
                <Border.Background>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#FF9D9D9D" Offset="0" />
                        <GradientStop Color="#FFDBDBDB" Offset="1" />
                    </LinearGradientBrush>
                </Border.Background>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Ellipse Fill="Black" HorizontalAlignment="Center" Width="4" Height="4" Margin="8,0"/>
                    <Ellipse Fill="Black" HorizontalAlignment="Center" Width="4" Height="4" Margin="8,0"/>
                    <Ellipse Fill="Black" HorizontalAlignment="Center" Width="4" Height="4" Margin="8,0"/>
                </StackPanel>
            </Border>
            <sdk:GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Background="Transparent" Opacity="0"/>

            <data:DataForm Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="DF" AutoCommit="False" 
                           DataContext="{Binding Path=Data, Mode=TwoWay}" ItemsSource="{Binding}" 
                           AutoGeneratingField="DF_AutoGeneratingField" EditEnded="DF_EditEnded" DeletingItem="DF_DeletingItem" Style="{StaticResource DataFormStyle}"/>

            <Grid Grid.Row="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Name="btnHideDF" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_HideDfBtn}" MinWidth="10" Margin="2" Click="btnHideDF_Click" />
                <Button Grid.Column="2" Name="bRefresh" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_RefreshBtn}" MinWidth="75" Margin="2" Click="bRefresh_Click" IsEnabled="{Binding Path=CanLoad}" />
                <Button Grid.Column="3" Name="btnCacnelChanges" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_CancelChangesBtn}" Margin="2" IsEnabled="{Binding Path=HasChanges}" Click="btnCacnelChanges_Click" Visibility="Collapsed" />
                <Button Grid.Column="4" Name="bSubmit" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_SubmitBtn}" MinWidth="75" Margin="2" IsEnabled="{Binding Path=HasChanges}" Click="bSubmit_Click" />
            </Grid>
        </Grid>

当视图显示在单个 Frame 中时,一切都很好。但是当它显示在具有两个框架的页面上时,奇怪的事情开始发生。如果用户抓住拆分器并将其一直移动到顶部,超出框架边界,DataForm 将无限扩展。这不是一个大问题,但它看起来很丑,并且使底部的按钮从视线中消失。

这是怎么回事?为什么会发生这种情况?我怎样才能防止这种行为?

I've got a generic view for displaying data in a Silverlight RIA application. Basically, the view takes in a parameter which is the query required by RIA to get the data, and the data is displayed using autogenerated fields.

Here's part of the XAML code for the view.

        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition x:Name="DataGridRow"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition x:Name="DataFormRow"/>
                <RowDefinition Height="Auto" x:Name="EditRow"/>
            </Grid.RowDefinitions>
            <ria:DomainDataSource Name="SQLDomainDataContext" LoadingData="SQLDomainDataContext_LoadingData" LoadSize="45" SubmittedChanges="SQLDomainDataContext_SubmittedChanges" SubmittingChanges="SQLDomainDataContext_SubmittingChanges" LoadedData="SQLDomainDataContext_LoadedData">
                <ria:DomainDataSource.SortDescriptors>
                    <ria:SortDescriptor Direction="Descending" PropertyPath="BaseProperties.CreatedOn" />
                </ria:DomainDataSource.SortDescriptors>
            </ria:DomainDataSource>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <sdk:DataGrid  Grid.Row="0" AutoGenerateColumns="True" Name="dataGrid" ItemsSource="{Binding}" DataContext="{Binding Path=Data, Mode=TwoWay}" IsReadOnly="True" AutoGeneratingColumn="dataGrid_AutoGeneratingColumn" SelectionChanged="dataGrid_SelectionChanged" />
                <custCont:LocalizedDataPager Grid.Row="1" x:Name="pager" Source="{Binding Path=Data}" PageSize="15" DisplayMode="FirstLastPreviousNext" />
            </Grid>

            <Border Grid.Row="1">
                <Border.Background>
                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                        <GradientStop Color="#FF9D9D9D" Offset="0" />
                        <GradientStop Color="#FFDBDBDB" Offset="1" />
                    </LinearGradientBrush>
                </Border.Background>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Ellipse Fill="Black" HorizontalAlignment="Center" Width="4" Height="4" Margin="8,0"/>
                    <Ellipse Fill="Black" HorizontalAlignment="Center" Width="4" Height="4" Margin="8,0"/>
                    <Ellipse Fill="Black" HorizontalAlignment="Center" Width="4" Height="4" Margin="8,0"/>
                </StackPanel>
            </Border>
            <sdk:GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Background="Transparent" Opacity="0"/>

            <data:DataForm Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="DF" AutoCommit="False" 
                           DataContext="{Binding Path=Data, Mode=TwoWay}" ItemsSource="{Binding}" 
                           AutoGeneratingField="DF_AutoGeneratingField" EditEnded="DF_EditEnded" DeletingItem="DF_DeletingItem" Style="{StaticResource DataFormStyle}"/>

            <Grid Grid.Row="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Name="btnHideDF" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_HideDfBtn}" MinWidth="10" Margin="2" Click="btnHideDF_Click" />
                <Button Grid.Column="2" Name="bRefresh" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_RefreshBtn}" MinWidth="75" Margin="2" Click="bRefresh_Click" IsEnabled="{Binding Path=CanLoad}" />
                <Button Grid.Column="3" Name="btnCacnelChanges" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_CancelChangesBtn}" Margin="2" IsEnabled="{Binding Path=HasChanges}" Click="btnCacnelChanges_Click" Visibility="Collapsed" />
                <Button Grid.Column="4" Name="bSubmit" Content="{Binding Source={StaticResource ApplicationResources}, Path=ApplicationStrings.ShowEntities_SubmitBtn}" MinWidth="75" Margin="2" IsEnabled="{Binding Path=HasChanges}" Click="bSubmit_Click" />
            </Grid>
        </Grid>

When the view is displayed in a singular Frame, all is well. But when it is displayed on a page with TWO frames, odd things begin to happen. If the user grabs the splitter and moves it all the way to the top, beyond the frames boundaries, the DataForm will expand endlessly. This isn't a big issue, but it looks ugly, and makes the buttons at the bottom vanish from sight.

What's going on here? Why is this happening? How can I prevent this behaviour?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪歌 2024-12-12 01:27:22

显然我的谷歌能力很弱。

我今天发现了这个,它也描述了我遇到的完全相同的问题作为一个可能的解决方案。

不过,我没想到这是 SL 中的一个错误......

Apparently my Google-fu was weak.

I found this today, and it describes the exact same problem I had, as well as a possible solution.

Still, I didn't expect this to be a bug in SL...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文