Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# xaml中的ResizeGrip样式忽略鼠标悬停触发器_C#_Wpf_Xaml - Fatal编程技术网

C# xaml中的ResizeGrip样式忽略鼠标悬停触发器

C# xaml中的ResizeGrip样式忽略鼠标悬停触发器,c#,wpf,xaml,C#,Wpf,Xaml,我目前正在使用以下xaml设置窗口的resizegrip样式,但它似乎忽略了ismouseover触发器 <Style x:Key="{x:Type ResizeGrip}" TargetType="{x:Type ResizeGrip}"> <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>

我目前正在使用以下xaml设置窗口的resizegrip样式,但它似乎忽略了ismouseover触发器

<Style x:Key="{x:Type ResizeGrip}" TargetType="{x:Type ResizeGrip}">
    <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
    <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
    <Setter Property="OverridesDefaultStyle" Value="true" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ResizeGrip}">
                <Grid Name="GripGrid" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
                    <Path Name="GripPath" Fill="Silver" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" Data="M 8,0 L 10,0 L 10,2 L 8,2 Z M 4,4 L 6,4 L 6,6 L 4,6 Z M 8,4 L 10,4 L 10,6 L 8,6 Z M 0,8 L 2,8 L 2,10 L 0,10 Z M 4,8 L 6,8 L 6,10 L 4,10 Z M 8,8 L 10,8 L 10,10 L 8,10 Z"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter TargetName="GripPath" Property="Fill" Value="Red"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

我只想更改鼠标上/下夹点的颜色。 谁能帮我一下,或者至少给我指出正确的方向

谢谢

从页面:

ResizeGrip
被定义为
窗口的可视树的一部分

因此,您需要更改
窗口的
控制模板
,以使
大小夹点的更改生效。将
样式设置为
窗口控件模板中
大小夹点样式的
动态资源

以下是根据MSDN页面改编的示例:

<Style x:Key="{x:Type Window}"
       TargetType="{x:Type Window}">
  <Setter Property="SnapsToDevicePixels"
          Value="true" />
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type Window}">
        <Grid>
          <Grid.Background>
            <SolidColorBrush Color="{DynamicResource WindowColor}"/>
          </Grid.Background>
          <AdornerDecorator>
            <ContentPresenter />
          </AdornerDecorator>
          <ResizeGrip x:Name="WindowResizeGrip"
                      HorizontalAlignment="Right"
                      VerticalAlignment="Bottom"
                      Visibility="Collapsed"
                      IsTabStop="false" />
                      Style="{DynamicResource YourStyle}"
        </Grid>
        <ControlTemplate.Triggers>
          <Trigger Property="ResizeMode"
                   Value="CanResizeWithGrip">
            <Setter TargetName="WindowResizeGrip"
                    Property="Visibility"
                    Value="Visible" />
          </Trigger>
        </ControlTemplate.Triggers>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

Style=“{dynamicResourceYourStyle}”

如果您不想对
样式做任何进一步的更改,您可以使用
静态资源

,如果有人需要这样的内容,我将发布我所做的(虽然不是我希望的那样)

我几乎放弃了为窗口的调整大小夹点设置ismouseover触发器。 我所做的是在我的窗口上放置一个thumb控件,并设置如下自定义样式:

    <Style x:Key="RzGripThumb" TargetType="{x:Type Thumb}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
        <Grid Name="GripGrid" SnapsToDevicePixels="True" Background="Transparent">
            <Path Name="GripPath" Fill="Gray" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" Data="F1M9,0L11,0 11,2 9,2 9,0z M9,9L11,9 11,11 9,11 9,9z M9,3L11,3 11,5 9,5 9,3z M9,6L11,6 11,8 9,8 9,6z M0,9L2,9 2,11 0,11 0,9z M3,9L5,9 5,11 3,11 3,9z M3,6L5,6 5,8 3,8 3,6z M6,9L8,9 8,11 6,11 6,9z M6,3L8,3 8,5 6,5 6,3z M6,6L8,6 8,8 6,8 6,6z"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter TargetName="GripPath" Property="Fill" Value="White"/>
            </Trigger>
            <Trigger Property="IsMouseCaptured" Value="true">
                <Setter TargetName="GripPath" Property="Fill" Value="Lime"/>
            </Trigger>
        </ControlTemplate.Triggers>
        </ControlTemplate>
    </Setter.Value>
</Setter>
</Style>

ResizeGrip
控制是否支持事件?。。。对这样的问题总是最好的。。。也许您应该编辑标题,以便更好地反映您的问题?从链接页面:
ResizeGrip
窗口的可视树的一部分。因此,您需要更改
窗口控制模板
,以使对
大小夹点
的更改生效。将您的
样式
设置为
窗口控件模板
中的
ResizeGrip样式
动态资源
。我尝试将其作为窗口样式的一部分,但似乎仍然无法获得效果。我尝试了两件事:简单地使用窗口样式,将resizegrip的样式设置为我的自定义样式(触发器位于resizegrip内),并且我还尝试在窗口样式中放置一个新的触发器,以用于。仍然没有出现颜色的变化。
double xadjust = this.ActualWidth + e.HorizontalChange;
double yadjust = this.ActualHeight + e.VerticalChange;
if ((xadjust >= this.MinWidth) && (yadjust >= this.MinHeight))
{
    this.Width = xadjust; 
    this.Height = yadjust;
}