RowDefinitions
및 ColumnDefinitions
그들은 Visuals
아닌, 시각적 트리에 실제로 아니다. 그것들은 단지 자식을 위치시키기 위해 Grid
에 의해서만 사용됩니다. 마음에 오는
한 가지 방법은 이러한 이벤트가 Grid
또는 Grid
자체에있는 아이를 제기 할 때 Grid
에 Mouse.MouseMove
및 Mouse.MouseLeave
통지받을 수있는 첨부 이벤트를 사용하는 것입니다. Mouse.MouseMove
이벤트 핸들러에서
<Grid Mouse.MouseMove="Grid_MouseMove"
Mouse.MouseLeave="Grid_MouseLeave"
Background="Transparent">
우리가 Grid
의 상대 마우스 위치를 얻을 MouseOverRowDefinition
처럼 연결된 속성에 현재 마우스로 hoovered되고있는 RowDefinition
계산하고 저장할 수 있습니다.
private void Grid_MouseMove(object sender, MouseEventArgs e)
{
Grid grid = sender as Grid;
Point mousePoint = e.GetPosition(grid);
double heightSum = grid.RowDefinitions[0].ActualHeight;
int activeRow = 0;
for (; heightSum < mousePoint.Y; activeRow++)
{
heightSum += grid.RowDefinitions[activeRow].ActualHeight;
}
GridExtensions.SetMouseOverRowDefinition(grid, activeRow);
}
// No RowDefinition is beeing hoovered, set MouseOverRowDefinition to -1
private void Grid_MouseLeave(object sender, MouseEventArgs e)
{
Grid grid = sender as Grid;
GridExtensions.SetMouseOverRowDefinition(grid, -1);
}
이제 우리는 MouseOverRowDefinition
에 대한 Grid
그래서 나머지는 Visible
여부를해야하는지 결정하는 Grid
에 대한 MouseOverRowDefinition
에 Image
에 대한 Grid.Row
비교의 문제입니다 조회 할 수 있습니다. 예제 프로젝트에 대한
http://dl.dropbox.com/u/39657172/MouseOverGridRowDefinition.zip
감사 :
당신이 그것을 시도하려는 경우 여기에이 작업을 수행 작은 샘플 응용 프로그램을 업로드! 난 여전히 코드에서 작동하도록 multibinding xaml 얻으려고 노력하고있어, 나는 조금 잃어버린 ... – epalm