我是否可以仅为一个xaml页面指定默认按钮样式? [英] Can I specify a default button style for only one xaml page?

查看:33
本文介绍了我是否可以仅为一个xaml页面指定默认按钮样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个Xaml页面中为按钮指定默认样式,这可能吗?  我在资源字典(rdButtons.xaml)中有我的按钮样式,然后我在用户控件中有各种按钮,它们将出现在主窗口的一部分中。
如果可能的话,我想集体应用一个默认样式到这些按钮。

I'd like to specify a default style for buttons in one Xaml page, is this possible?  I have my button style in a resource dictionary (rdButtons.xaml) and then I have a variety of buttons in a user control that will appear in a portion of the main window. I'd like to apply a single default style en masse, if possible, to those buttons.

谢谢你帮助。

Purkiss

推荐答案

是的,假设你的风格有钥匙(在我的例子中,ButtonStyle1),如下所示:

Yes, assuming your style has a key (in my case, ButtonStyle1), like this:

<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="SilverlightApplication29.MainPage"
	Width="640" Height="480">
	<UserControl.Resources>
		<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle1}"/>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" Background="White">
		<Button Content="Button" HorizontalAlignment="Left" Margin="80,207,0,153" Width="131" />
		<Button Content="Button" HorizontalAlignment="Right" Height="107" Margin="0,103,161,0" VerticalAlignment="Top" Width="148"/>
		<Button Content="Button" HorizontalAlignment="Right" Height="106" Margin="0,0,161,74" VerticalAlignment="Bottom" Width="82"/>
	</Grid>
</UserControl>


这篇关于我是否可以仅为一个xaml页面指定默认按钮样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆