惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

博客园 - 李大力

开始整理WPF学习笔记 一定要知道的十八个人情世故 wpf wcf 折磨人啊 sessionState config 树立自己的品牌形象 Ajax 的 webservice 配置问题 Reflection facebook 项目 facebook 关于silverlight 1.0 RC 无题 String Handling and Regular Expressions 昨天的教训 InterView 我离mircosoft还有多远? DropdownList 动态添加项为什么不好用? 《The World Is Flat》-----How the World Became Flat 心情很复杂 自定义控件学习(1)
wpf 做的一个小东西
李大力 · 2007-08-28 · via 博客园 - 李大力

一个新的项目想用 WPF 来做,我做了小例子,做为可行性的分析。

主要是用到grid layout 的一些方法,贴出来供以后做参考。

using System;
using System.Collections.Generic;
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 WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        int mRow = -1;
        int mColumn = -1;
        MediaElement me;

        public Window1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
          
          
        }

        private void mediaElement1_DragEnter(object sender, DragEventArgs e)
        {
            MessageBox.Show(sender.ToString());
        }

        private void play_Click(object sender, RoutedEventArgs e)
        {
          
       
        }

        private void mediaElement1_Drop(object sender, DragEventArgs e)
        {

        }

        private void mediaElement1_MouseLeave(object sender, MouseEventArgs e)
        {
          
        }

        private void mediaElement1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (sender.GetType().ToString() == "System.Windows.Controls.Label")
            {
                if (mRow > -1)
                {
                    int Column = Grid.GetColumn(this.Lable1);
                    int Row = Grid.GetRow(this.Lable1);

                    //  int mRow = Grid.GetRow(this.mediaElement1);
                    //  int mColumn = Grid.GetColumn(this.mediaElement1);

                    Grid.SetColumn(me, Column);
                    Grid.SetRow(me, Row);

                    Grid.SetColumn(this.Lable1, mColumn);
                    Grid.SetRow(this.Lable1, mRow);

                    mRow = -1;
                }
            }
        }

        private void mediaElement2_DragEnter(object sender, DragEventArgs e)
        {
            
        }

        private void mediaElement1_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
        {
            me = sender as MediaElement;
           
            mRow = Grid.GetRow(me);
            mColumn = Grid.GetColumn(me);
        }

       

    }
}

xmal:

    <Grid Background="AliceBlue">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Label Background="Aqua" Grid.Column="0" Grid.Row="0" Name="Lable1" MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp" />
        <MediaElement Grid.Column="1" Grid.Row="1" Source="1.wmv"  Name="mediaElement1" AllowDrop="True" MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <MediaElement Grid.Column="2" Grid.Row="2" Source="1.wmv"  Name="mediaElement4" AllowDrop="True" MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <MediaElement Grid.Column="0" Grid.Row="1" Source="trexchicken.wmv"  Name="mediaElement2" AllowDrop="True"  MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <MediaElement Grid.Column="3" Grid.Row="1" Source="trexchicken.wmv"  Name="mediaElement3" AllowDrop="True"  MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <Image Name="five" Grid.Column="2" Grid.Row="0" />
        <Button Height="23" Grid.Row="4" Name="button1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Click="button1_Click">Change</Button>
        <Button Height="23" Grid.Row="3" Name="play" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Click="play_Click">play</Button>
    </Grid>