我有一个用户控件:
<UserControl x:Class="livetile.smalltile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="159" d:DesignWidth="159">
<Canvas x:Name="LayoutRoot" Background="Black" Width="159" Height="159">
<TextBlock x:Name="day" Text="16" Width="159" TextAlignment="Center" FontSize="100" Foreground="White"/>
<TextBlock x:Name="dayofweek" Text="Saturday" Width="159" TextAlignment="Center" Canvas.Top="100"FontSize="30" Margin="0,0,0,25" Foreground="White"/>
</Canvas>
</UserControl>
然后我将其转换为可写位图:
public WriteableBitmap GetBmp()
{
this.Measure(new Size(159, 159));
this.Arrange(new Rect(0, 0, 159, 159));
// draw bmp
var bmp = new WriteableBitmap(159, 159);
bmp.Render(this, null);
bmp.Invalidate();
return bmp;
}
然后,我使用此可写位图来渲染JPG并保存它。问题是图像只显示画布的背景颜色,而不是其中的文本......我该如何解决这个问题?
看起来它与我用于TextBlocks的自定义字体有关。