silverlight乐动魔方 实战八 .
好了··上次讲到···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葵花宝典
----------------------------
用心做产品 name:5+x
----------------------------
用心做产品 name:5+x
----------------------------
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端