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
指定在按下鼠标按键且鼠标指针位于控件上方时应引发,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 眼馋那