문제

누군가 WPF에서 스크롤 뷰어의 스크롤 바를 테스트하는 방법을 알려주시겠습니까?

감사,

앤디

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <StackPanel>
        <ScrollViewer Name="myScrollViewer" Width="280" Height="200" MouseMove="ScrollViewer_MouseMove" >


        </ScrollViewer>

        <TextBox Name="myTextBox"></TextBox>
    </StackPanel>
</Window>

뒤에 코드 ...

using System.Windows.Input;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void ScrollViewer_MouseMove(object sender, MouseEventArgs e)
        {
            myTextBox.Text = e.GetPosition(myScrollViewer).X + "," + e.GetPosition(myScrollViewer).Y;
        }

    }
}
도움이 되었습니까?

해결책

와 함께 VisualTreeHelper.Hittest, Mouseeventargs는 ScrollViewer와 관련이 있으므로 첫 번째 매개 변수는 ScrollViewer입니다. 그런 다음 사용하십시오 PointhittestEtParameter Mouseeventargs의 좌표와 함께.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top