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

推荐订阅源

Google DeepMind News
Google DeepMind News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 【当耐特】
博客园_首页
博客园 - Franky
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
D
Docker
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
S
SegmentFault 最新的问题
腾讯CDC
Latest news
Latest news
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
美团技术团队
C
Cybersecurity and Infrastructure Security Agency CISA
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
C
Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
T
Threat Research - Cisco Blogs
F
Full Disclosure
T
Threatpost
T
Tenable Blog
AWS News Blog
AWS News Blog
Cloudbric
Cloudbric
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
W
WeLiveSecurity
I
Intezer
月光博客
月光博客
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
Lohrmann on Cybersecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"

博客园 - 李大力

开始整理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>