English 中文(简体)
如何确定控制是否在WPF的窗口/制表控制链中进行
原标题:How to identify whether the control is going inside the window / tab control bounds in WPF

我想使控制高峰翻一番,因为当暴徒离开控制时,控制高峰应当变得正常。

我认为,我使用以下风格,使纽托邦的高度翻一番,因为 mo在一顿。

<Style TargetType="{x:Type Buttons}">  
<Style.Triggers>  
    <Trigger Property="IsMouseOver" Value="True">  
        <Setter Property="RenderTransform"> 
            <Setter.Value> 
                <ScaleTransform ScaleX="1" ScaleY="2" /> 
            </Setter.Value> 
        </Setter> 
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>  
        <Setter Property="Panel.ZIndex" Value="99999"/>  
    </Trigger>  
</Style.Triggers>  

如果 but子位于窗户/制表控制边界附近,那么,当塔顿延伸时,它就在塔博控制/窗口控制区内。 (在潮湿时)

我不想让纽子走在塔夫控制/寡妇控制区内。

相反,当纽伦触及塔博控制/寡妇约束时,纽伦应移到窗户内(必须改变Render TransformOrigin)。

随函附上了我的Sample Application for You referencehere

最佳回答

您可尝试在您的Render TransformOrigin 集邮器上使用一个转机。

兑换商将接受控制作为参数,并检查其母体内的控制位置是否在0到2之间(ControlHels / 2),如果是计算和返还不同的Render TransformOrigin值。 否则,只是退回违约(0.5,0.5)

Edit: To answer your comment, I m not sure of the exact syntax since I m not testing this, but I was thinking something similar to the following:

创建您的转换者。 可能必须成为多巴inding转换器

public class RenderTransformConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        // Get parameters - You ll probably want to include validation and default values
        UIElement control = (UIElement)value[0];            
        UIElement parent = (UIElement)value[1];

        int controlHeight = control.Height;
        int controlXPositionInParent = control.TranslatePoint(new Point(0, 0), parent).X;

        if (controlXPositionInParent < (controlHeight * .5))
        {
            // Calculate a new render transform. 
            // Should verify I m doing the math right, didn t get much sleep last night
            return new Point(0.5, controlXPositionInParent / controlHeight);
        }
        else
        {
            return new Point(0.5, 0.5);
        }
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

您的XAML将包括一条线,把改名空间包括在内,并为新皈依者制造一个物体。

<localNamespace:RenderTransformConverter x:Key="renderTransformConverter />

嗣后: 类似情况是:

<Setter Property="RenderTransformOrigin">
<Setter.Value>
    <MultiBinding Converter="{StaticResource renderTransformConverter}">
        <Binding Path="{Binding RelativeSource=Self}" />
        <Binding Path="{Binding RelativeSource=Self, Path=Parent}" />
    </MultiBinding>
</Setter.Value>

如果你能够把控制作为变压器的参数,那么我不会感到乐观,但如果你可能不得不重新安排参数,以获得计算所需的任何数值。

问题回答

暂无回答




相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签