Skip to main content
.NET Framework Class Library
FrameworkElementBringIntoView Method (Rect)

Attempts to bring the provided region size of this element into view, within any scrollable regions it is contained within.

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
Syntax
Public Sub BringIntoView ( _
	targetRectangle As [%$TOPIC/ms598115_en-us_VS_110_1_0_0_0_0%] _
)
public void BringIntoView(
	[%$TOPIC/ms598115_en-us_VS_110_1_0_1_0_0%] targetRectangle
)
public:
void BringIntoView(
	[%$TOPIC/ms598115_en-us_VS_110_1_0_2_0_0%] targetRectangle
)
member BringIntoView : 
        targetRectangle:[%$TOPIC/ms598115_en-us_VS_110_1_0_3_0_0%] -> unit
public function BringIntoView(
	targetRectangle : [%$TOPIC/ms598115_en-us_VS_110_1_0_4_0_0%]
)

Parameters

targetRectangle
Type: System.WindowsRect

Specified size of the element that should also be brought into view.

Remarks

By calling this method, you raise a RequestBringIntoView event that originates from the current element. This event is raised so that it can be handled by a ScrollViewer, or a derived or similar class. The expected behavior is that the event is handled by the parent element, marked handled in the event data, and the source of the event is brought into view through the logic embedded in the ScrollViewer control. Neither the RequestBringIntoView event nor the BringIntoView method transmit any information about success or failure, other than that the event is typically marked handled on success. Reasons for failure can include the element settings, such as Visibility being some value other than Visible.

If you use the signature that does not specify a targetRectangle, then the entire element size (its RenderSize) will be made visible.

By calling this method, you potentially will call MakeVisible on any parent scrollable area that contains the element. If this element is not contained in a scrollable area, the RequestBringIntoView event is still raised, but there will be no effect because there are no event listeners.

Examples

The following example has a large graphic in a constrained scrolling region. A button on the page has a handler that scrolls the view to a particular region of the large graphic.

<ScrollViewer Width="300" Height="300" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
  <Image Name="mapframe" ScrollViewer.CanContentScroll="True"  >
    <Image.Source>
      <BitmapImage UriSource="treasuremap.bmp"/>
    </Image.Source>
  </Image>
</ScrollViewer>
<StackPanel>
  <Button Click="GoToLake">Go to Lake</Button>

</StackPanel>
		Private Sub GoToLake(ByVal sender As Object, ByVal e As RoutedEventArgs)
			mapframe.BringIntoView(New Rect(800, 400, 200, 200))
		End Sub
void GoToLake(object sender, RoutedEventArgs e)
{
    mapframe.BringIntoView(new Rect(800, 400, 200, 200));
}
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1