【发布时间】:2013-11-16 16:29:15
【问题描述】:
我有一个用户控件:
<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>
然后我将其转换为 WriteableBitmap:
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;
}
然后我使用这个 WriteableBitmap 来渲染 JPG 并保存它。问题是图像只显示画布的背景颜色,而不是其中的文本......我该如何解决这个问题?
【问题讨论】:
标签: c# user-controls windows-phone writeablebitmap