I am having trouble trying to create ScrollBars/ScrollViewers permanent access. I am working on a data entry application where some users may only have read permissions. To do this, disable all controls so that they do not make any changes.
When the control is disabled, the user cannot view all the information in the scrollable controls (Infragistics XamDataGrid , DevExpress GridControl , TextBox es with Wrap, ListBox , etc.). I was hoping I could outsmart Microsoft and implement Trigger to set IsEnabled to true when it was set to false, but of course it didn't work (for various reasons, I'm sure).
At the moment, I focus strictly on the text field to try to disable the content, but I support ScrollViewer and no luck.
I was hoping there could be a solution, I.E. Overriding the IsEnabled dependency property of a ScrollViewer always returns true or provides some type of Style that prevents ScrollViewer .
I know that TextBox has IsReadOnly property, but it is useless for many other controls that I need to solve this problem.
Is there a way to solve this in a fairly simple way (just as in that I can make a style that applies everywhere without changing files with code over 200+).
thanks
EDIT: Here is the code I'm using in a sample project to try and solve this problem.
<Window x:Class="WPFScrollViewerStyles.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <Style BasedOn="{x:Null}" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Microsoft_Windows_Themes:ListBoxChrome x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" SnapsToDevicePixels="true"> <ScrollViewer x:Name="PART_ContentHost" HorizontalScrollBarVisibility="Visible" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" IsEnabled="True" /> </Microsoft_Windows_Themes:ListBoxChrome> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="false"> <Setter Property="IsEnabled" Value="True" TargetName="PART_ContentHost" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid IsEnabled="False"> <Grid.ColumnDefinitions> <ColumnDefinition Width="100" /> <ColumnDefinition Width="100" /> <ColumnDefinition Width="100" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="100" /> <RowDefinition Height="100" /> <RowDefinition Height="100" /> </Grid.RowDefinitions> <TextBox x:Name="txtScroller" Width="100" Height="100" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" ScrollViewer.CanContentScroll="True"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras faucibus hendrerit lorem, auctor vehicula sem molestie nec. Quisque non massa quam. Nullam tempor blandit tempor. Integer in molestie ipsum. Donec augue mi, auctor vitae scelerisque a, vehicula ac ipsum. Etiam posuere vulputate augue quis convallis. Nullam aliquet purus nec lacus fermentum hendrerit egestas purus tincidunt. Suspendisse quis lacinia libero. Quisque facilisis turpis at augue dignissim aliquam ultrices sem porta. Etiam sagittis arcu id nibh ultrices dictum. Nulla non lectus luctus est malesuada luctus. Praesent sed lobortis nisi. Morbi et porttitor massa. Sed pellentesque, nisl eu imperdiet varius, ligula augue cursus nisl, eu egestas metus velit non elit. Phasellus elementum hendrerit risus, eu tincidunt ante gravida vel. </TextBox> <ListBox x:Name="lstScroller" Width="100" Height="100" Grid.Column="1"> <ListBox.Items> <ListBoxItem Content="Item 1" /> <ListBoxItem Content="Item 2" /> <ListBoxItem Content="Item 3" /> <ListBoxItem Content="Item 4" /> <ListBoxItem Content="Item 5" /> <ListBoxItem Content="Item 6" /> <ListBoxItem Content="Item 7" /> <ListBoxItem Content="Item 8" /> <ListBoxItem Content="Item 9" /> <ListBoxItem Content="Item 10" /> <ListBoxItem Content="Item 11" /> <ListBoxItem Content="Item 12" /> <ListBoxItem Content="Item 13" /> <ListBoxItem Content="Item 14" /> <ListBoxItem Content="Item 15" /> </ListBox.Items> </ListBox> </Grid>