我正在使用Windows Phone的Code4fun工具包中的消息提示。
我在设计组件样式时遇到问题。我试着为它创建一个通用的stye,也试着在显示组件之前更改属性:
var messagePrompt = new MessagePrompt
{
Title = "UserControl test",
Body = new PopupView(),
IsAppBarVisible = true,
IsCancelVisible = true,
BorderThickness = new Thickness(0),
Margin = new Thickness(0),
Padding = new Thickness(0),
BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 82, 161)),
Background = new SolidColorBrush(Color.FromArgb(255, 0, 82, 161))
};
messagePrompt.Show();
背景设置为正确的颜色,但边框厚度、边距和填充设置被忽略!
我试过在谷歌上搜索一些令人困惑的例子,但运气不好!
那么,如何根据coding4fun对MessagePrompt组件进行样式设置呢?
这是来自Code4fun:的MessagePrompt模板
<Grid VerticalAlignment="Stretch">
<Rectangle Fill="{StaticResource TransparentBrush}" />
<Border VerticalAlignment="Top"
Margin="10" // because this line you can't change margin
Background="{TemplateBinding Background}"
BorderThickness="1" // because this line you can't change BorderThickness
BorderBrush="{StaticResource PhoneForegroundBrush}">
<StackPanel Margin="10">
<TextBlock Text="{TemplateBinding Title}"
Margin="0,-10,-25,10" FontSize="30"
TextWrapping="Wrap" FontFamily="Segoe WP Light" />
<ContentPresenter Content="{TemplateBinding Body}" />
<StackPanel Margin="0,10,0,0"
Name="actionButtonArea"
Orientation="Horizontal"
HorizontalAlignment="Center" />
</StackPanel>
</Border>
</Grid>
已忽略填充,因为此属性未在模板中使用。您可以看到,如果您想更改此属性,您必须更改MessagePrompt的模板。