마우스 밑에 엔티티가있을 수있는 3D 렌더링이 있습니다. 엔티티에 대한 정보가있는 툴팁이 필요하며 아래 코드를 사용하여이를 수행 할 수 있습니다. 팁은 마우스가 엔터티 위에있을 때 항상 보이고 그렇지 않으면 숨겨집니다. XAML에서 WPF ToolTip 동적 표시/숨기기를 어떻게 얻을 수 있습니까?
// Would like to do this in XAML - it must be possible but not sure how
string toolTipString = null;
public void SetToolTipString()
{
var e = _worldViewModel.MouseOverEntity;
string newTip = e == null ? null : e.Entity.Name;
if (newTip != toolTipString)
{
toolTipString = newTip;
if (newTip == null)
{
if (ToolTip != null)
{
((ToolTip)ToolTip).IsOpen = false;
}
ToolTip = null;
}
else
{
ToolTip = new ToolTip { Content = toolTipString, IsOpen = true, StaysOpen = true };
}
}
}
나는이 시도했지만 작동하지 않았다 : XAML에 그것을 달성 할 수있는 방법이
<ToolTip
StaysOpen="True"
IsOpen="{Binding Path=PlacementTarget.DataContext.IsMouseOverEntity,
RelativeSource={RelativeSource Self}}"
Content="{Binding Path=PlacementTarget.DataContext.MouseOverEntity.Entity.Name,
RelativeSource={RelativeSource Self}}"/>
있습니까?
당신이 보여줄 수 HTH? –
나는 그 질문을 이해하지 못한다. _worldViewModel.MouseOverEntity는 마우스 아래의 3D 요소를 포함합니다. DataContext가 _worldViewModel로 설정되었습니다. XAML 바인딩은 콘텐츠에 대해서는 작동하지만 IsOpen 적합성에 대해서는 작동하지 않는 것 같습니다. –
바인딩 오류가 발생하고 있습니까? – kevindaub