XAML Telerik DataGrids导致页面在低分辨率和非全屏窗口上被截断
本文关键字:窗口 分辨率 DataGrids Telerik XAML | 更新日期: 2023-09-27 18:25:01
我很感激你花时间帮我解决这个问题。。。
正如下面的代码所示,我有Telerik DataGrids。当窗口向下恢复时,它只会剪切网格的中间部分,不会让你在页面或数据网格上滚动。页面的网格和边框应该根据用户浏览器的高度进行调整。并根据需要自动插入滚动条。
我在其他页面上也实现了同样的方法,效果很好,但这个页面很顽固。
再次,提前感谢您的帮助和时间!
<---下面的代码--->
<controls:ViewBase
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
x:Class="CS.Sentry.Silverlight.Module.DataSetup.UpdatePrice.UpdatePriceView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:CS.Sentry.Silverlight.Library.Controls;assembly=Library"
xmlns:GenericComponents="clr-namespace:CS.Sentry.Silverlight.ComponentLibraries.GenericComponents;assembly=GenericComponents"
xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
xmlns:data="clr-namespace:CS.Sentry.Library.Controls.Data;assembly=Library.Controls"
xmlns:CustomControls="clr-namespace:CS.Sentry.Library.Controls.CustomControls;assembly=Library.Controls"
xmlns:Controls="clr-namespace:CS.Sentry.Library.Controls;assembly=Library.Controls"
xmlns:CArt_Layout="clr-namespace:ComponentArt.Silverlight.UI.Layout;assembly=ComponentArt.Silverlight.UI.Layout"
xmlns:Controls1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView">
<Grid x:Name="LayoutRoot" Margin="0,1,0,0">
<Grid.RowDefinitions>
<!--Header-->
<RowDefinition Height="Auto" />
<!--Data Tables-->
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--Header-->
<Border Grid.Row="0" Margin="0,0,0,0" Style="{StaticResource borderStyle}">
<Grid>
<Grid.ColumnDefinitions>
<!--Column Zero-->
<ColumnDefinition Width="*"></ColumnDefinition>
<!--Column One-->
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!--Row Zero-->
<RowDefinition Height="*" />
<!--Row One-->
<RowDefinition Height="*" />
<!--Row Two-->
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--StackPanel-->
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0" Margin="5,5,0,5" >
<Controls:CustomRadioButton Margin="0,2,0,0" Width="80" Content="Held" VerticalAlignment="Center" IsChecked="{Binding IsHeldChecked,Mode=TwoWay}" GroupName="PriceType"></Controls:CustomRadioButton>
<GenericComponents:GenericPicker x:Name="Selector" Margin="0,0,10,0" AsOfDate ="{Binding AsOfDate, Mode=TwoWay}" FilterType="Filter" Title ="Select" SelectedItems ="{Binding Selected, Mode=TwoWay}" ></GenericComponents:GenericPicker>
<RadioButton x:Name="RadioButton1" Content="First" VerticalAlignment="Center" GroupName="Group" IsChecked="{Binding First, Mode=TwoWay}" HorizontalAlignment="Center" Margin="0,2,3,1"></RadioButton>
<RadioButton x:Name="RadioButton2" Content="Second" VerticalAlignment="Center" GroupName="Group" IsChecked="{Binding Second,Mode=TwoWay}" HorizontalAlignment="Center"></RadioButton>
</StackPanel>
<!--StackPanel-->
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" Margin="5,5,0,2" x:Name="SelectedPanel">
<Controls:CustomRadioButton Margin="0,2,0,0" Width="80" Content="Selected" VerticalAlignment="Center" GroupName="Type" IsChecked="{Binding IsSelectedChecked,Mode=TwoWay}"></Controls:CustomRadioButton>
<GenericComponents:GenericPicker x:Name="Selector" Margin="0,0,10,0" AsOfDate ="{Binding AsOfDate, Mode=TwoWay}" FilterType="Filter" Title ="Select" SelectedItems ="{Binding Selected, Mode=TwoWay}" ></GenericComponents:GenericPicker>
</StackPanel>
<!--Date Range-->
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" Margin="15,5,0,2" Grid.RowSpan="2">
<CustomControls:GenericCalendarControl IsRange="False" Margin="10,0,0,0"
SelectedDateMnemonic="{Binding AsOfDateMnemonic, Mode=TwoWay}"
SelectedEndDate="{Binding AsOfDate, Mode=TwoWay}"/>
</StackPanel>
<!--Refresh/Authority-->
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="5,5,0,5" Grid.ColumnSpan="2">
<Button x:Name="refreshButton" Content="Refresh" Margin="3,0,3,0" Height="25" Width="120" cal:Click.Command="{Binding RefreshCommand}" ></Button>
<TextBlock Text="Text1: " Style="{StaticResource textBlockStyle}" Width="120" Margin="30,1,0,0"></TextBlock>
<ComboBox VerticalAlignment="Center" HorizontalAlignment="Left" ItemsSource="{Binding Items,Mode=TwoWay}" DisplayMemberPath="Name" Height="22" Width="200" Margin="0,1,20,0" SelectedItem ="{Binding Item,Mode=TwoWay}"/>
<Controls:CustomButton VerticalAlignment="Center" Height="21" HorizontalAlignment="Right" Content="Field Chooser"
cal:Click.Command="{Binding FieldChooserCommand}"
ToolTipService.ToolTip="Select additional fields">
</Controls:CustomButton>
<Controls:CustomCheckBox VerticalAlignment="Center" Content="Ignore Overrides" IsChecked="{Binding IgnoreOverrides,Mode=TwoWay}" Margin="20,1,20,0" ToolTipService.ToolTip="Override"/>
<Controls:CustomButton VerticalAlignment="Center" Height="21" HorizontalAlignment="Right" Content="View Overrides" Click="ViewOverrides_Click"/>
<Controls:CustomButton x:Name="Update" VerticalAlignment="Center" Margin="10" Height="21" HorizontalAlignment="Right" Content="Download" cal:Click.Command="{Binding Command}"
Visibility="Collapsed" ToolTipService.ToolTip="Downloads"/>
</StackPanel>
</Grid>
</Border>
<!--Data Tables-->
<Border Grid.Row="1" Margin="0,0,0,0" Style="{StaticResource borderStyle}" VerticalAlignment="Top">
<!--Side By Side Grids-->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<!--Grid One-->
<ColumnDefinition Width="0.59*"></ColumnDefinition>
<!--Splitter-->
<ColumnDefinition Width="0.02*"></ColumnDefinition>
<!--Grid Two-->
<ColumnDefinition Width="0.39*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<!--Grid One, Splitter, Grid Two-->
<RowDefinition Height="0.925*" />
<!--Footer-->
<RowDefinition Height="0.075*" />
</Grid.RowDefinitions>
<!--Grid One-->
<Grid Grid.Row="0" Grid.Column="0">
<Grid.RowDefinitions>
<!--Grid-->
<RowDefinition Height="0.95*" />
<!--Label/Buttons-->
<RowDefinition Height="0.05*" />
</Grid.RowDefinitions>
<!--Grid-->
<data:CustomDataGrid Grid.Row="0" Margin="5,16,0,5" ShowGroupPanel="False" VerticalAlignment="Top" x:Name="priceDatagrid" Background="Transparent" AutoGenerateColumns="False"
ItemsSource="{Binding info,Mode=TwoWay}" IsReadOnly="False" SelectedItem="{Binding infoItem,Mode=TwoWay}"
CanUserFreezeColumns="False" CanUserResizeColumns="True" CanUserReorderColumns="False" IsFilteringAllowed="False" ScrollMode="RealTime" VerticalContentAlignment="Stretch">
<Controls1:RadGridView.Columns>
<Controls1:GridViewDataColumn Header="Col1" DataMemberBinding="{Binding ID, Mode=TwoWay}" IsReadOnly="True" Width="45"/>
<Controls1:GridViewDataColumn Header="Col2" DataMemberBinding="{Binding Name, Mode=TwoWay}" IsReadOnly="True" Width="100"/>
<Controls1:GridViewDataColumn Header="Col3" DataMemberBinding="{Binding Scheme, Mode=TwoWay}" IsReadOnly="True" Width="60"/>
<Controls1:GridViewDataColumn Header="Col4" DataMemberBinding="{Binding Default, Mode=TwoWay}" IsReadOnly="True" Width="105"/>
<Controls1:GridViewDataColumn Header="Col5" UniqueName="Date" DataMemberBinding="{Binding AsOfDate, Mode=TwoWay}" IsReadOnly="True" Width="105"/>
<Controls1:GridViewDataColumn Header="Col6" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Price, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col7" UniqueName="Spread" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Spread, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col8" UniqueName="Bid" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Bid, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col9" UniqueName="Ask" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Ask, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col10" UniqueName="Depth" TextAlignment="Right" Width="50" DataMemberBinding="{Binding Depth, Converter={StaticResource mathValueConverter}, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col11" UniqueName="Volume" TextAlignment="Right" Width="120" DataMemberBinding="{Binding Volume, Converter={StaticResource mathValueConverter}, ConverterParameter=2, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col12" UniqueName="Outstanding" TextAlignment="Right" Width="120" DataMemberBinding="{Binding Outstanding, Converter={StaticResource mathValueConverter}, ConverterParameter=2, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Col13" UniqueName="Currency" TextAlignment="Left" Width="60" DataMemberBinding="{Binding Currency, Mode=TwoWay}" IsReadOnly="True" />
<Controls1:GridViewDataColumn Header="Col14" DataMemberBinding="{Binding Notes, Mode=TwoWay}" Width="180"/>
</Controls1:RadGridView.Columns>
</data:CustomDataGrid>
<!--Import/Export Buttons-->
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5,0,0,0" HorizontalAlignment="Left">
<Button x:Name="exportButton" Padding="5" Content="Export" Height="25" Width="70" Margin="3,1,3,1" cal:Click.Command="{Binding ExportCommand}" ></Button>
<Button x:Name="importButton" Padding="5" Content="Import" Height="25" Width="70" Margin="3,1,3,1" cal:Click.Command="{Binding ImportFileCommand}" ></Button>
</StackPanel>
<!--Info Label-->
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5,0,0,0" HorizontalAlignment="Right">
<TextBlock x:Name="InformationLabel" Width ="500" Foreground="#FF15428B" Text="Prices in this grid will be updated as-of the date selected at the top of the screen. Sentry will not use the Prior Pricing Date. The Prior Pricing Date is informational only." Height="30" Margin="3,1,3,1" TextWrapping="Wrap" FontWeight="Bold" FontSize="10"></TextBlock>
</StackPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<!--Splitter to expand/compress-->
<CArt_Layout:Splitter CollapseDirection="Right" ShowsPreview="False" x:Name="ySplitter" Background="Transparent"></CArt_Layout:Splitter>
</Grid>
<Grid Grid.Row="0" Grid.Column="2">
<!--Grid Two-->
<telerik:GroupBox Header="History" x:Name="PriceGroupBox" Margin="0" VerticalAlignment="Top" HorizontalAlignment="Stretch" >
<Grid>
<Grid.RowDefinitions>
<!--Menu-->
<RowDefinition Height="0.05*"/>
<!--Grid-->
<RowDefinition Height="0.8*" />
<!--Pager-->
<RowDefinition Height="0.05*"/>
<!--Buttons-->
<RowDefinition Height="0.05*"/>
<!--Footer-->
<RowDefinition Height="0.05*"/>
</Grid.RowDefinitions>
<!--Menu-->
<TextBlock Grid.Row="0" Margin="0" x:Name="proxyOverrideMsgTextBlock" Style="{StaticResource textBlockStyle}" Text="{Binding ProxyOverrideMsg}" Visibility="{Binding ProxyOverrideMsgVisibility}" TextWrapping="Wrap" VerticalAlignment="Top" />
<!--Grid-->
<data:CustomDataGrid Grid.Row="1" Margin="0" ShowGroupPanel="False" x:Name="Datagrid" Background="Transparent" AutoGenerateColumns="False"
ItemsSource="{Binding PriceInfos,Mode=TwoWay}" SelectedItem="{Binding PriceInfo,Mode=TwoWay}" IsReadOnly="False" VerticalAlignment="Top"
CanUserFreezeColumns="False" CanUserResizeColumns="True" CanUserReorderColumns="False" IsFilteringAllowed="False" ScrollMode="RealTime" VerticalContentAlignment="Stretch">
<Controls1:RadGridView.Columns>
<Controls1:GridViewDataColumn Header="Date" UniqueName="Date" DataMemberBinding="{Binding AsOfDate, Mode=TwoWay}" IsReadOnly="False" Width="75"/>
<Controls1:GridViewDataColumn Header="Value" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Price, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Spread" UniqueName="Spread" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Spread, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Bid" UniqueName="Bid" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Bid, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Ask" UniqueName="Ask" TextAlignment="Right" Width="70" DataMemberBinding="{Binding Ask, Converter={StaticResource mathValueConverter}, ConverterParameter=6, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Depth" UniqueName="Depth" TextAlignment="Right" Width="50" DataMemberBinding="{Binding Depth, Converter={StaticResource mathValueConverter}, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Volume" UniqueName="Volume" TextAlignment="Right" Width="120" DataMemberBinding="{Binding Volume, Converter={StaticResource mathValueConverter}, ConverterParameter=2, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Outstanding" UniqueName="Outstanding" TextAlignment="Right" Width="120" DataMemberBinding="{Binding Outstanding, Converter={StaticResource mathValueConverter}, ConverterParameter=2, Mode=TwoWay}" />
<Controls1:GridViewDataColumn Header="Currency" UniqueName="Currency" TextAlignment="Left" Width="60" DataMemberBinding="{Binding Currency, Mode=TwoWay}" IsReadOnly="True" />
<Controls1:GridViewDataColumn Header="Notes" DataMemberBinding="{Binding Notes, Mode=TwoWay}" Width="80"/>
<Controls1:GridViewDataColumn Header="Update User" DataMemberBinding="{Binding UpdateUser, Mode=TwoWay}" IsReadOnly="True" Width="80"/>
<Controls1:GridViewDataColumn Header="Update Date" UniqueName="Update Date" DataMemberBinding="{Binding UpdateDate, Mode=TwoWay}" IsReadOnly="True" Width="130"/>
</Controls1:RadGridView.Columns>
</data:CustomDataGrid>
<!--Pager-->
<telerik:RadDataPager Grid.Row="2" x:Name="datagridPager" PageSize="20" Margin="0,0,5,0" Visibility="{Binding DataGridVisibility,Mode=TwoWay}" Source="{Binding Items, ElementName=Datagrid, Mode=TwoWay}" DisplayMode="All" AutoEllipsisMode="Both" NumericButtonCount="10" IsTotalItemCountFixed="True"/>
<!--Add/Remove/Export Buttons-->
<Grid Grid.Row="3" Margin="0,2,0,0" >
<telerik:RadButton x:Name="addButton" Content="+" Margin="0,1,0,1" Height="25" Width="40" HorizontalAlignment="Left" cal:Click.Command="{Binding AddCommand, Mode=TwoWay}"></telerik:RadButton>
<Button x:Name="removeButton" Content="-" Margin="45,1,0,1" Height="25" Width="40" HorizontalAlignment="Left" cal:Click.Command="{Binding RemoveCommand, Mode=TwoWay}"></Button>
<Button x:Name="exportButton" Content="Export" Margin="10,1,5,1" Height="25" Width="70" HorizontalAlignment="Right" cal:Click.Command="{Binding ExportCommand, Mode=TwoWay}"></Button>
</Grid>
</Grid>
</telerik:GroupBox>
</Grid>
<!--Footer-->
<Grid Grid.Row="1" Grid.Column="0" ColumnSpan="3">
<StackPanel Orientation="Horizontal" Margin="5,10,8,10" HorizontalAlignment="Right">
<Button x:Name="SaveButton" Content="Save" Margin="0,1,0,1" Height="25" Width="70" HorizontalAlignment="Right" Click="SaveButton_Click"></Button>
<Button x:Name="CancelButton" Content="Cancel" Margin="10,1,0,1" Height="25" Width="70" HorizontalAlignment="Right" Click="CancelButton_Click" ></Button>
</StackPanel>
</Grid>
</Grid>
</Border>
</Grid>
尝试将数据的垂直对齐:CustomDataGrid设置为"拉伸"