ScrollViewer内のコントロールの位置を設定する † ScrollViewerコントロールに HorizontalContentAlignmentとVerticalContentAlignmentプロパティが提供していますが、ScrollViewerコントロールの中にCanvasコントロールを入れる場合、HorizontalContentAlignmentとVerticalContentAlignmentプロパティを設定しても、実際に反映しません スクロール際のイベント †共通的なイベント発生させるメソッドのソースコード: public static void RegisterForNotification( //プロパティ名 string property, //対象コントロール名 FrameworkElement frameworkElement, //コールバックメソッド PropertyChangedCallback OnCallBack ) { Binding binding = new Binding(property) { Source = frameworkElement }; var dependencyproperty = System.Windows.DependencyProperty.RegisterAttached("ListenAttached" + property, typeof(object), typeof(UserControl), new System.Windows.PropertyMetadata(OnCallBack)); frameworkElement.SetBinding(dependencyproperty, binding); } 垂直スクロールバーのスクロールイベントの場合、propertyパラメータを「VerticalOffset」に設定します、水平は「HorizontalOffset」に設定します。 public void OnVerticalOffsetChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //e.NewValue } iディレクトリで複数のポータルサイトにディレクトリ登録 コメント: |