Hakoyu / StarsectorToolbox

For the game Starsector provides many functions such as mod management, game settings, etc.
MIT License
11 stars 3 forks source link

右键菜单显示在鼠标左侧时位置偏移的问题 #4

Open Hakoyu opened 1 year ago

Hakoyu commented 1 year ago

菜单显示在右边时 image

菜单显示在左边时 image

可以看到有很大程度的偏移 因为将pu:ContextMenuHelper.ItemsWidth设置为了NaN根据字符串长度来改变菜单长度 但是没有完全改变菜单的实际长度(鼠标和菜单间隔的这一段依旧是菜单的一部分,只是看不到了而已)

  <Style
    x:Key="ContextMenu_Style"
    BasedOn="{StaticResource {x:Type ContextMenu}}"
    TargetType="ContextMenu">
    <Setter Property="Background" Value="{DynamicResource ColorBG}" />
    <Setter Property="BorderBrush" Value="{DynamicResource ColorLight3}" />
    <Setter Property="Foreground" Value="{DynamicResource ColorFG}" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Width" Value="NaN" />
    <Setter Property="pu:ShadowHelper.ShadowDepth" Value="3" />
    <Setter Property="pu:ContextMenuHelper.ShadowColor" Value="{DynamicResource ColorAqua}" />
    <Setter Property="pu:ContextMenuHelper.ItemsWidth" Value="NaN" />
    <!--<Setter Property="pu:ContextMenuHelper.ItemsIconWidth" Value="0"/>-->
    <Setter Property="pu:ContextMenuHelper.ItemsHoverBackground" Value="{DynamicResource ColorLight2}" />
    <Setter Property="pu:ContextMenuHelper.ItemsCheckedBackground" Value="{DynamicResource ColorLightBlue2}" />
    <Setter Property="pu:ToolTipHelper.Background" Value="{DynamicResource ColorBG}" />
    <Setter Property="pu:ToolTipHelper.Foreground" Value="{DynamicResource ColorFG}" />
    <Setter Property="pu:ToolTipHelper.ShadowColor" Value="{DynamicResource ColorAqua}" />
  </Style>