Hi,
How I can control maximum value of horizontal scroll bar in the xamSpreadhsheet control? For what ever reasons I have around 5-10 columns in control but scrollbar shows very high value while all columns fits into the screen. How I can adjust this behavior?
Thanks in advance,
Tomas
Hello Tomas,
My team and I have done an initial review of this support case, and I have some questions for you relating to the XamSpreadsheet and the Excel file you are placing inside it, as the behavior you are currently seeing is not the default, and there does not exist a way to control the “max scroll” of the XamSpreadsheet as it depends on the allocated cells. The default behavior can be seen in just about any of the XamSpreadsheet samples within the WPF Samples Browser that is installable with the product.
Would it be possible for you to please answer the following?
1. What is the container that you have the XamSpreadsheet placed inside of? By chance is it within a ScrollViewer / StackPanel / other control that measures with an infinite height/width?
2. Are there other cells that may have had values in the Workbook that you are applying to the XamSpreadsheet than the ones in your screenshot? I ask this, as the XamSpreadsheet and the Excel Workbooks/Worksheets only actually allocate cells that have a value or have had a value and this is done for performance reasons, as allocating them all would be horrible for performance. A way you can check what cells (or how many) are allocated is to run the following foreach loop, where “sheet” is the active Worksheet of the XamSpreadsheet:
foreach(var row in sheet.Rows) { System.Diagnostics.Debug.WriteLine("Row " + rowCount);
foreach(var cell in row.Cells) { System.Diagnostics.Debug.WriteLine("Cell " + cellCount); cellCount++; }
rowCount++; }
Please let me know if you have any other questions or concerns on this matter.
Hi Andrew,
I've made minor corrections to the code to have smaller output and attached directly to spreadsheet activate workbook event:
private void SpreadSheet_OnActiveWorksheetChanged(object sender, SpreadsheetActiveWorksheetChangedEventArgs e) { System.Diagnostics.Debug.WriteLine("Worksheet name: " + e.NewValue.Name); var rowCount = 0; foreach (var row in e.NewValue.Rows) { var cellCount = 0; foreach (var cell in row.Cells) cellCount++; System.Diagnostics.Debug.WriteLine($"Row {rowCount} with {cellCount} Cells"); rowCount++; } }
This generated output for previously shown screenshot:
Worksheet name: Variables Row 0 with 8 Cells Row 1 with 0 Cells Row 2 with 1 Cells Row 3 with 0 Cells Row 4 with 1 Cells Row 5 with 1 Cells Row 6 with 1 Cells Row 7 with 1 Cells Row 8 with 1 Cells Row 9 with 1 Cells Row 10 with 1 Cells Row 11 with 1 Cells Row 12 with 0 Cells Row 13 with 0 Cells Row 14 with 0 Cells Row 15 with 0 Cells Row 16 with 0 Cells Row 17 with 0 Cells Row 18 with 0 Cells Row 19 with 0 Cells Row 20 with 0 Cells Row 21 with 0 Cells Row 22 with 0 Cells Row 23 with 0 Cells Row 24 with 0 Cells Row 25 with 0 Cells Row 26 with 0 Cells Row 27 with 0 Cells Row 28 with 0 Cells Row 29 with 0 Cells Row 30 with 0 Cells Row 31 with 0 Cells Row 32 with 0 Cells Row 33 with 0 Cells Row 34 with 0 Cells Row 35 with 0 Cells Row 36 with 0 Cells Row 37 with 0 Cells Row 38 with 0 Cells Row 39 with 0 Cells Row 40 with 0 Cells Row 41 with 0 Cells
The Xaml source code has own parents located in multiple levels of tabs then loaded as user control with fallowing xaml:
<UserControl xmlns:ig="http://schemas.infragistics.com/xaml" x:Class="EafClient.Editor.CellAutomation.EquipmentDictionary.Views.EquipmentDictionaryEditorView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:multiconverters="clr-namespace:EafClient.Core.Converters.MultiConverters;assembly=EafClient.Core" xmlns:igWindows="http://infragistics.com/Windows" xmlns:common="clr-namespace:EafClient.Core.Images.Common;assembly=EafClient.Core" xmlns:specificBehaviors="clr-namespace:EafClient.Editor.CellAutomation.EquipmentDictionary.Views.SpecificBehaviors" xmlns:edit="clr-namespace:EafClient.Outlook.IntegratorViews;assembly=EafClient.Outlook" mc:Ignorable="d"> <UserControl.Resources> <multiconverters:MultiBooleanOrConverter x:Key="BooleanOrConverter" /> <multiconverters:MultiBooleanToVisibilityConverter x:Key="MultiBooleanConverter" /> </UserControl.Resources> <i:Interaction.Behaviors> <specificBehaviors:EquipmentDictionaryWorkbookBehavior> <specificBehaviors:EquipmentDictionaryWorkbookBehavior.WorkbookData> <Binding Path="EquipmentDictionaryWorkbook" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/> </specificBehaviors:EquipmentDictionaryWorkbookBehavior.WorkbookData> <specificBehaviors:EquipmentDictionaryWorkbookBehavior.IsSpreadsheetDirty> <Binding Path="UnsavedChangesExist" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/> </specificBehaviors:EquipmentDictionaryWorkbookBehavior.IsSpreadsheetDirty> <specificBehaviors:EquipmentDictionaryWorkbookBehavior.ActiveWorksheetName> <Binding Path="ActiveWorksheetName" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/> </specificBehaviors:EquipmentDictionaryWorkbookBehavior.ActiveWorksheetName> <specificBehaviors:EquipmentDictionaryWorkbookBehavior.AddWorksheetEvents> <Binding Path="AddWorksheetEvents" Mode="OneWay" UpdateSourceTrigger="PropertyChanged" /> </specificBehaviors:EquipmentDictionaryWorkbookBehavior.AddWorksheetEvents> <specificBehaviors:EquipmentDictionaryWorkbookBehavior.IsReadOnly> <MultiBinding Converter="{StaticResource BooleanOrConverter}"> <Binding Path="DataContext.IsFrozen" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type edit:IViewAdapter}}" Mode="OneWay" /> <Binding Path="IsReadOnlyMode" Source="{x:Static Application.Current}" Mode="OneWay" /> </MultiBinding> </specificBehaviors:EquipmentDictionaryWorkbookBehavior.IsReadOnly> </specificBehaviors:EquipmentDictionaryWorkbookBehavior> </i:Interaction.Behaviors> <Grid> <DockPanel LastChildFill="True" x:Name="dockPanel"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Top"> <Button Opacity="100" Style="{DynamicResource ImageButton}" IsDefault="True" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3" ToolTip="Add a new Object worksheet based on the template." Command="{Binding CreateAndSelectObjectWorksheetCommand}" CommandParameter="{Binding EquipmentDictionaryWorkbook}"> <StackPanel> <igWindows:AutoDisabledImage Source="{Binding Source={x:Static common:GeneralIcon.NEW}}" Stretch="Fill" Height="15" Width="15"/> </StackPanel> </Button> <Button Opacity="100" Style="{DynamicResource ImageButton}" IsDefault="True" IsEnabled="{Binding IsObjectWorksheet}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3" ToolTip="Rename active Worksheet." Command="{Binding RenameObjectWorksheetCommand}" CommandParameter="{Binding EquipmentDictionaryWorkbook}"> <StackPanel> <igWindows:AutoDisabledImage Source="{Binding Source={x:Static common:GeneralIcon.RENAME}}" Stretch="Fill" Height="15" Width="15"/> </StackPanel> </Button> <Button Opacity="100" Style="{DynamicResource ImageButton}" IsDefault="False" IsEnabled="{Binding IsObjectWorksheet}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3" ToolTip="Delete the selected Worksheet." Command="{Binding DeleteObjectWorksheetCommand}" CommandParameter="{Binding EquipmentDictionaryWorkbook}"> <StackPanel> <igWindows:AutoDisabledImage Source="{Binding Source={x:Static common:GeneralIcon.DELETE}}" Stretch="Fill" Height="15" Width="15"/> </StackPanel> </Button> <StackPanel.Visibility> <MultiBinding Converter="{StaticResource MultiBooleanConverter}" ConverterParameter="inverse:1,2"> <Binding Path="DataContext.IsFrozen" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type edit:IViewAdapter}}" Mode="OneWay" /> <Binding Path="IsReadOnlyMode" Source="{x:Static Application.Current}" Mode="OneWay" /> </MultiBinding> </StackPanel.Visibility> </StackPanel> <ig:XamSpreadsheet x:Name="SpreadSheet" ActiveWorksheetChanged="SpreadSheet_OnActiveWorksheetChanged" AllowAddWorksheet="False" AllowDeleteWorksheet="False" FontFamily="{Binding EquipmentDictionaryFontFamily}" FontSize="{Binding EquipmentDictionaryFontSize}"> <ig:XamSpreadsheet.ContextMenuProvider> <ig:SpreadsheetContextMenuProvider> <ig:SpreadsheetContextMenuProvider.ResourceOverrides> <ResourceDictionary> <!-- Empty Tab Context Menu to prevent Rename via context menu--> <ig:XamContextMenu x:Key="Tab"/> </ResourceDictionary> </ig:SpreadsheetContextMenuProvider.ResourceOverrides> </ig:SpreadsheetContextMenuProvider> </ig:XamSpreadsheet.ContextMenuProvider> </ig:XamSpreadsheet> </DockPanel> </Grid> </UserControl>
The location of the xamSpreadhsheet control is hard to describe but here screenshot of Xaml tree view to the control from application level (used tool Snoop v2.10.0.0):
I've highlighted various containers and other our controls. Hope this helps.