Silverlight4入门之rectangle控件(四)

<UserControl x:Class="FirstSilverlightApplication.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White">
        <Rectangle Height="138" HorizontalAlignment="Left" Margin="0,0,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="258" Fill="#FFF27979" MouseMove="rectangle1_MouseMove" MouseRightButtonDown="rectangle1_MouseRightButtonDown" MouseRightButtonUp="rectangle1_MouseRightButtonUp" MouseWheel="rectangle1_MouseWheel" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,177,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="258" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,217,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="258" />
    </Grid>
</UserControl>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FirstSilverlightApplication
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
           
        }

        private void rectangle1_MouseMove(object sender, MouseEventArgs e)
        {
            textBlock1.Text = e.GetPosition(this).X.ToString();
            textBlock2.Text = e.GetPosition(this).Y.ToString();
        }

        private void rectangle1_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            rectangle1.Fill = new SolidColorBrush(Colors.Yellow);
            e.Handled = true;
        }

        private void rectangle1_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            rectangle1.Fill = new SolidColorBrush(Colors.Green);
        }

        private void rectangle1_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta > 0)
            {
                textBlock1.Text = "Up";
            }
            else
            {
                textBlock1.Text = "Down";
            }
        }

      
    }
}

 
阅读更多
个人分类: Silverlight
想对作者说点什么? 我来说一句

MICROSOFT SILVERLIGHT 4从入门到精通

2016年11月17日 42.3MB 下载

silverlight4富文本控件

2010年06月04日 549KB 下载

Silverlight4入门之Grid控件(八)

suzhi921 suzhi921

2011-10-17 12:08:53

阅读数:410

silverlight4学习源码

2011年06月02日 2.23MB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭