WPF Cursors

最近在研究WPF,寻找与光标有关的东西,做了一个小界面,只要copy以下code,就可以见到光标的效果.

XAML代码:

<Window x:Class="UI3APP2008.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
    <Grid>
        <ComboBox Height="23" Margin="69,85,89,0" Name="comboBox1" VerticalAlignment="Top" SelectionChanged="comboBox1_SelectionChanged" />
    </Grid>
</Window>

C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UI3APP2008
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            BindCBX();
        }
        private void BindCBX()
        {
            comboBox1.Items.Add(Cursors.AppStarting);
            comboBox1.Items.Add(Cursors.Arrow);
            comboBox1.Items.Add(Cursors.ArrowCD);
            comboBox1.Items.Add(Cursors.Cross);
            comboBox1.Items.Add(Cursors.Hand);
            comboBox1.Items.Add(Cursors.Help);
            comboBox1.Items.Add(Cursors.IBeam);
            comboBox1.Items.Add(Cursors.No);
            comboBox1.Items.Add(Cursors.None);
            comboBox1.Items.Add(Cursors.Pen);
            comboBox1.Items.Add(Cursors.ScrollAll);
            comboBox1.Items.Add(Cursors.ScrollE);
            comboBox1.Items.Add(Cursors.ScrollN);
            comboBox1.Items.Add(Cursors.ScrollNE);
            comboBox1.Items.Add(Cursors.ScrollNW);
            comboBox1.Items.Add(Cursors.ScrollS);
            comboBox1.Items.Add(Cursors.ScrollSE);
            comboBox1.Items.Add(Cursors.ScrollSW);
            comboBox1.Items.Add(Cursors.ScrollW);
            comboBox1.Items.Add(Cursors.ScrollWE);
            comboBox1.Items.Add(Cursors.SizeAll);
            comboBox1.Items.Add(Cursors.SizeNESW);
            comboBox1.Items.Add(Cursors.SizeNS);
            comboBox1.Items.Add(Cursors.SizeNWSE);
            comboBox1.Items.Add(Cursors.SizeWE);
            comboBox1.Items.Add(Cursors.UpArrow);
            comboBox1.Items.Add(Cursors.Wait);
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
           
        }
        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            this.Cursor = (Cursor)comboBox1.SelectedItem;
        }
    }
}

只要点击comboBox下拉列表,就可以即时看到效果哦.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值