如何在Storyboard中设置光标

时间:2017-09-17 12:27:53

标签: uwp uwp-xaml

当我的视频播放器的媒体传输控件淡出时,我试图更换光标。我想在控件淡出时隐藏它。 我想在这里添加:

function checkpnummer() {

 if(!$('#patientnummer').val().match(/^\d{8}$/)) {
  $('#patientnummer').css({"background-color": "#CD5C5C"});
  alert("Vul een patientnummer in dat bestaat uit 8 cijfers.");
 }
 else {
  $("#patientnummer").css("background-color", "#00FA9A");
  $("#patientnummer").focusout();
 }
}
}

1 个答案:

答案 0 :(得分:-1)

我应该在代码中写一个属性。

      public static readonly DependencyProperty CursorProperty = DependencyProperty.Register(
        "Cursor", typeof(string), typeof(MainPage), new PropertyMetadata(default(string), (s, e) =>
        {
            if (e.NewValue != null)
            {
                Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor((CoreCursorType) Enum.Parse(typeof(CoreCursorType), (string) e.NewValue), 0);
            }
            else
            {
                Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(CoreCursorType.Arrow, 0);

            }
        }));

    public string Cursor
    {
        get { return (string) GetValue(CursorProperty); }
        set { SetValue(CursorProperty, value); }
    }

设置将设置光标的光标。

你可以在xaml中更改Cursor,请参阅代码。

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState x:Name="wideView">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="720" />
                </VisualState.StateTriggers>
                <VisualState.Storyboard>
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Page" Storyboard.TargetProperty="Cursor">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="IBeam"></DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState.Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

我写道,当窗口大小大于720时,将使用IBeam,我认为你可以使用它。

您可以下载http://7xqpl8.com1.z0.glb.clouddn.com/UhajoloraKdzvhy.zip

中的所有代码
相关问题