silverlight樂動魔方 實戰八 .

來源:互聯網
上載者:User

好了··上次講到···childwindows 幹啥的?~》

 

這次就看看··吧··

如果你之前下載了····PicBtn 這個檔案,···那就應該會有以下的圖片

接著就是他的XAML布局

<controls:ChildWindow x:Class="SilverlightMusicHit.ChildMusicMsg"           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"            xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"           Width="400" Height="300"            Opacity="0.9" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input">    <Grid x:Name="LayoutRoot" Margin="2" LostFocus="LayoutRoot_LostFocus">        <Grid.RowDefinitions>            <RowDefinition Height="150"/>            <RowDefinition Height="50"/>            <RowDefinition Height="Auto" />        </Grid.RowDefinitions>        <Button x:Name="btnStart" Content="START" Width="126" Height="63" HorizontalAlignment="Right" Margin="0,0,125,-28" Grid.Row="2" Opacity="0.5" MouseLeave="btn_MouseLeave" MouseMove="btn_MouseMove" Click="btnStart_Click" />        <Image Height="150" Width="150" HorizontalAlignment="Left" Margin="0,0,0,0" Name="imgMusic" Stretch="Fill" VerticalAlignment="Top" Grid.Row="0" Source="../Image/PicBtn/musicMsg.png"/>        <TextBlock Height="140" HorizontalAlignment="Left" Margin="150,10,0,0" Name="txtMusicTitle" VerticalAlignment="Top" Width="230" FontSize="32" Text="txt" TextWrapping="Wrap" />    </Grid></controls:ChildWindow>

- = 怎麼越講越少,····怎麼說呢···其實這些布局···應該還看得懂吧。

進入···ChildMusicMsg.cs才是重點

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;using System.Threading;namespace SilverlightMusicHit{    public partial class ChildMusicMsg : ChildWindow    {        #region 變數        /// <summary>        /// 音樂資訊索引        /// </summary>        private static int _musicIndex = 0;         #endregion        public ChildMusicMsg(int musicIndex)        {            InitializeComponent();            _musicIndex = musicIndex;            //讀取音樂資訊            txtMusicTitle.Text = Common._MusicValue[_musicIndex].MusicName;        }        /// <summary>        /// 滑鼠移過按鈕高亮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void btn_MouseMove(object sender, MouseEventArgs e)        {            ((Button)sender).Opacity = 1;        }        /// <summary>        /// 滑鼠離開按鈕恢複        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void btn_MouseLeave(object sender, MouseEventArgs e)        {            ((Button)sender).Opacity = 0.5;        }        private void btnStart_Click(object sender, RoutedEventArgs e)        {            ((App)(Application.Current)).RedirectTo(new Game(_musicIndex));            this.DialogResult = true;        }        private void LayoutRoot_LostFocus(object sender, RoutedEventArgs e)        {            this.DialogResult = true;        }    }}

噢··還有錯誤,···,嗯,還要建立一個新的表單,··Game , 進入遊戲了··呵呵··· - =  不過下一章才講~

好了··就這樣吧···

name:5+x

 

參考文章與書籍:

WPF葵花寶典

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.