windows phone (27) 基础Button
Button 在wp7中因其灵活性经常会用到,我们在ContentPanel中直接添加Button,button默认状态下是把整个gridview填充完全,比如代码这样的代码
<!--ContentPanel - 在此处放置其他内容-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="点击我" BorderBrush="Red" BorderThickness="10"></Button>
</Grid>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="点击我" BorderBrush="Red" BorderThickness="10"></Button>
</Grid>
其呈现效果
从上面的图片我们可以看出button显示的文字是textblock,边缘是border,所以我们还可以继续给button添加一些属性,比如字体,背景色,等等一些textblock和border的属性
<!--ContentPanel - 在此处放置其他内容-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="点击我" BorderBrush="DarkGoldenrod"
BorderThickness="10" FontSize="50" FontFamily="Portable User Interface"
FontStyle="Italic" Foreground="Navy"
>
</Button>
</Grid>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="点击我" BorderBrush="DarkGoldenrod"
BorderThickness="10" FontSize="50" FontFamily="Portable User Interface"
FontStyle="Italic" Foreground="Navy"
>
</Button>
</Grid>
<!--ContentPanel - 在此处放置其他内容-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="点击我" BorderBrush="DarkGoldenrod"
BorderThickness="10" FontSize="50" FontFamily="Portable User Interface"
FontStyle="Italic" Foreground="Navy" Width="300" Height="200" Padding="50 10" Margin="12,0,12,0" ClickMode="Press"
>
</Button>
</Grid>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="点击我" BorderBrush="DarkGoldenrod"
BorderThickness="10" FontSize="50" FontFamily="Portable User Interface"
FontStyle="Italic" Foreground="Navy" Width="300" Height="200" Padding="50 10" Margin="12,0,12,0" ClickMode="Press"
>
</Button>
</Grid>
clickMode属性
Release
指定当按下并松开鼠标左键且鼠标指针位于控件上方时应引发,如果使用的是键盘,则指定在按下并松开空格键或 Enter 键且控件具有键盘焦点时应引发 Press
指定在按下鼠标按键且鼠标指针位于控件上方时应引发,如果使用的是键盘,则指定在按下空格键或 Enter 且控件具有键盘焦点时应引发 Click 事件(话说这个比较适合于广告)
Hover
指定当鼠标指针在控件上移动时应引发 Click 事件。
Content
System.Object
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.ContentControl
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.ContentControl
凡是继承此类的元素都可以具有content属性
由于PC的项目,已经两三个月没有更新wp的文章了,群里每天都在讨论win 8,wp8 眼馋那
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?