FrameworkElement.BringIntoView メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
スクロール可能な領域内で、この要素をビューに取り込もうとします。
オーバーロード
| 名前 | 説明 |
|---|---|
| BringIntoView(Rect) |
この要素の指定された領域サイズを、その中に含まれているスクロール可能な領域内で表示しようとします。 |
| BringIntoView() |
スクロール可能な領域内で、この要素をビューに取り込もうとします。 |
BringIntoView(Rect)
この要素の指定された領域サイズを、その中に含まれているスクロール可能な領域内で表示しようとします。
public:
void BringIntoView(System::Windows::Rect targetRectangle);
public void BringIntoView(System.Windows.Rect targetRectangle);
member this.BringIntoView : System.Windows.Rect -> unit
Public Sub BringIntoView (targetRectangle As Rect)
パラメーター
- targetRectangle
- Rect
表示する必要がある要素の指定されたサイズ。
例
次の例では、制約付きスクロール領域に大きなグラフィックがあります。 ページ上のボタンには、大きなグラフィックの特定の領域までビューをスクロールするハンドラーがあります。
<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>
void GoToLake(object sender, RoutedEventArgs e)
{
mapframe.BringIntoView(new Rect(800, 400, 200, 200));
}
Private Sub GoToLake(ByVal sender As Object, ByVal e As RoutedEventArgs)
mapframe.BringIntoView(New Rect(800, 400, 200, 200))
End Sub
注釈
このメソッドを呼び出すと、現在の要素から発生した RequestBringIntoView イベントが発生します。 このイベントは、 ScrollViewer、または派生クラスまたは同様のクラスで処理できるように発生します。 予期される動作は、イベントが親要素によって処理され、イベント データで処理済みとしてマークされ、イベントのソースが、 ScrollViewer コントロールに埋め込まれたロジックを通じて表示されるということです。 RequestBringIntoView イベントもBringIntoViewメソッドも、成功または失敗に関する情報は送信しません。イベントは通常、成功時に処理済みとマークされます。 エラーの理由には、Visibility以外の値であるVisibleなど、要素の設定が含まれる場合があります。
targetRectangleを指定しない署名を使用すると、要素のサイズ全体 (そのRenderSize) が表示されます。
このメソッドを呼び出すことで、要素を含む親スクロール可能領域で MakeVisible を呼び出す可能性があります。 この要素がスクロール可能領域に含まれていない場合、 RequestBringIntoView イベントは引き続き発生しますが、イベント リスナーがないため影響はありません。
こちらもご覧ください
適用対象
BringIntoView()
スクロール可能な領域内で、この要素をビューに取り込もうとします。
public:
void BringIntoView();
public void BringIntoView();
member this.BringIntoView : unit -> unit
Public Sub BringIntoView ()
例
次の例では、一様リソース識別子 (URI) にフラグメントが含まれるたびに応答するアプリケーション ナビゲーション イベントのハンドラーを実装します。 フラグメントはハッシュ記号 (#)に続く URI で名前が付けられ、実装された動作により、要素はフレーム内でスクロールして表示されます。 BringIntoView と RequestBringIntoView 例のスクロール動作を要求します。
void browserFrame_FragmentNavigation(object sender, FragmentNavigationEventArgs e)
{
object content = ((ContentControl)e.Navigator).Content;
FrameworkElement fragmentElement = LogicalTreeHelper.FindLogicalNode((DependencyObject)content, e.Fragment) as FrameworkElement;
if (fragmentElement == null)
{
// Redirect to error page
// Note - You can't navigate from within a FragmentNavigation event handler,
// hence creation of an async dispatcher work item
this.Dispatcher.BeginInvoke(
DispatcherPriority.Send,
(DispatcherOperationCallback) delegate(object unused)
{
this.browserFrame.Navigate(new Uri("FragmentNotFoundPage.xaml", UriKind.Relative));
return null;
},
null);
e.Handled = true;
}
}
Private Sub browserFrame_FragmentNavigation(ByVal sender As Object, ByVal e As FragmentNavigationEventArgs)
Dim element As FrameworkElement = TryCast(LogicalTreeHelper.FindLogicalNode(DirectCast(DirectCast(e.Navigator, ContentControl).Content, DependencyObject), e.Fragment), FrameworkElement)
If (element Is Nothing) Then
' Redirect to error page
' Note - You can't navigate from within a FragmentNavigation event handler,
' hence creation of an async dispatcher work item
Dim callback As New DispatcherOperationCallback(AddressOf Me.FragmentNotFoundNavigationRedirect)
Me.Dispatcher.BeginInvoke(DispatcherPriority.Normal, callback, Nothing)
End If
e.Handled = True
End Sub
Function FragmentNotFoundNavigationRedirect(ByVal unused As Object) As Object
Me.browserFrame.Navigate(New Uri("FragmentNotFoundPage.xaml", UriKind.Relative))
Return Nothing
End Function
注釈
このメソッドを呼び出すと、現在の要素から発生した RequestBringIntoView イベントが発生します。 このイベントは、 ScrollViewer、または派生クラスまたは同様のクラスで処理できるように発生します。 予期される動作は、イベントが親要素によって処理され、イベント データで処理済みとしてマークされ、イベントのソースが、 ScrollViewer コントロールに埋め込まれたロジックを通じて表示されるということです。 RequestBringIntoView イベントもBringIntoViewメソッドも、成功または失敗に関する情報は送信しません。イベントは通常、成功時に処理済みとマークされます。 エラーの理由には、Visibility以外の値であるVisibleなど、要素の設定が含まれる場合があります。
targetRectangleを指定しない署名を使用すると、要素のサイズ全体 (そのRenderSize) が表示されます。
このメソッドを呼び出すことで、要素を含む親スクロール可能領域で MakeVisible を呼び出す可能性があります。 この要素がスクロール可能領域に含まれていない場合、 RequestBringIntoView イベントは引き続き発生しますが、イベント リスナーがないため影響はありません。