scrollviewer

C# WPF - ScrollViewer + TextBlock troubles

主宰稳场 提交于 2019-11-30 08:13:19
I have a TextBlock within a ScrollViewer that aligns with stretch to its window. I need the TextBlock to behave as the following: Resizes with window, no scrollbars When resized below a certain width the TextBlock needs to keep a MinWidth and scrollbars should appear TextWrapping or TextTrimming should work appropriately How can I get this functionality? I have tried several ways, involving bindings to ActualWidth & ActualHeight , but can't get it to work. This can't be that difficult, what am I missing? Here is a code sample to put in XamlPad (no MinWidth is set yet): <Window xmlns="http:/

How to scroll WPF ScrollViewer's content to specific location

拈花ヽ惹草 提交于 2019-11-30 07:53:29
问题 I am writing my custom WPF ItemsControl to display a list of item. The items are shown embedded inside a ScrollViewer: <Style TargetType="MyCustomItemsControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="MyCustomItemsControl"> <ScrollViewer x:Name="PART_MyScrollViewer" > <ItemsPresenter/> </ScrollViewer> </ControlTemplate> </Setter.Value> </Setter> </Style> I want to make sure that when I move the mouse into the control, a particular item (marked as selected)

How to find Vertical Scrollbar width of a Scrollviewer in C#

时光怂恿深爱的人放手 提交于 2019-11-30 07:49:51
问题 I have a ScrollViewer and in that I am showing the Vertical Scrollbar, Now on changing resolution of the system I want to get the width of the scrollbar. I went through One StackOverflow Post there they mention to check for SystemParameters.ScrollWidth Property but again I din find any help from their. Can anybody please help me to fix my issue. Any answer will be appreciated. 回答1: I think SystemParameters.VerticalScrollBarWidth is what you are looking for. 回答2: I am not sure if this is the

How to make scrollviewer work with Height set to Auto in WPF?

风流意气都作罢 提交于 2019-11-30 06:57:15
问题 I have learned that if the height of a grid row, where the ScrollViewer resides, is set as Auto , the vertical scroll bar will not take effect since the actual size of the ScrollViewer can be larger than the height in sight. So in order to make the scroll bar work, I should set the height to either a fixed number or star height However, I now have this requirement, that I have two different views reside in two grid rows, and I have a toggle button to switch between these two views: when one

Stop WPF ScrollViewer automatically scrolling to perceived content

有些话、适合烂在心里 提交于 2019-11-30 05:43:43
The Application I am building an application which includes a range selector. This consists of two custom drawn Slider controls contained within one UserControl derived class. The range selector control is then contained inside a ScrollViewer which has the HorizonalScrollBar visible most of the time. Sample Application Code: ( appologies for the wall of text ) Window.xaml ( the Window file ): <Grid> <ScrollViewer x:Name="ScrollViewer" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled"> <local:SliderTest x:Name="slider" LowerValue="0" UpperValue="10" Minimum="0"

Calculate Horizontal Offset to scroll ListView to the center of the SelectedItem

試著忘記壹切 提交于 2019-11-30 05:43:35
I am building a photo application, using a FlipView and a listView as a Pagination. When I click on the thumbnail picture in the ListView it shows me the same picture in the FlipView . And when I swipe into the FlipView , any photo selected will select the same picture in the ListView . This is done by adding to both of them: To the ListView : SelectedIndex="{Binding Path=SelectedIndex, ElementName=flipView1, Mode=TwoWay} And to the FlipView : SelectedIndex="{Binding Path=SelectedIndex, ElementName=listView1, Mode=TwoWay} And to the ListView SelectionChanged event I added: if (e.AddedItems

ScrollViewer is not working in WPF WindowsFormHost

不问归期 提交于 2019-11-30 05:12:23
I have WindowsFormHost with a RichTextBox in my WPF form, i have given ScrollViewer for that WindowsFormHost but its not working, WindowsFormHost going outside of ScrollViewer... My XAML is.. <ScrollViewer Background="DarkOrange" VerticalScrollBarVisibility="Auto" Height="80" MaxHeight="85" Margin="11,243,12,218" Width="756"> <Canvas Height="100" Name="canvas1" Width="auto" > <WindowsFormsHost ClipToBounds="True" Height="120" Width="715" Margin="10,5,0,0" Name="winHostTEst" Background="Gray"> <wf:RichTextBox BackColor="Cornsilk" Text="RichTextBox" x:Name="richTbTest" BorderStyle="None" Enabled

WPF ListView Always show complete items

懵懂的女人 提交于 2019-11-30 03:58:21
问题 I've got an app with multiple ListView controls where there's a requirement that the item's in the ListView must be fully visible. There should never be partial ListViewItem's showing in the list. If the user releases the ScrollViewer at a position that ends up showing a partial item, then the list should "snap" and correct itself so that only complete items are displayed. Has anyone done this before? I think I'm going to need to overload ListView and/or ScrollViewer to do this. I'm looking

How to place a ScrollViewer on top of the content it should scroll

混江龙づ霸主 提交于 2019-11-29 18:53:06
问题 I would like to put my ScrollViewer in such a way that it overlaps/sits on top of the content it scrolls. I would set the Opacity of the ScrollViewer so that the content is visible underneath. As far as I understand the default ScrollViewer, this doesn't seem to be possible out of the box since the content is nested inside the ScrollViewer. Any ideas on how to make this work? EDIT: I understand that the ScrollViewer is a Decorator and that the content is not aware of the ScrollViewer. This

ScrollBars are not visible after changing positions of controls inside a Canvas

放肆的年华 提交于 2019-11-29 16:08:59
I created a custom canvas control inheriting from WPF Canvas . I am using it like this in main window - <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <RTD:RTDesignerCanvas Margin="5" Background="White" x:Name="canvas1" Focusable="True" AllowDrop="True"> </RTD:RTDesignerCanvas> </ScrollViewer> Everything works fine but when I try to set the position of controls inside it like this Canvas.SetTop(item, 200); scrollbars are not visible and control is hidden down somewhere. Interestingly, if I add another control to it scroll bars are visible and I can