Silverlight 4.0 如何在Windowsphone7中提供更改TextBlock前景色、大小的选项

Silverlight 4.0 如何在Windowsphone7中提供更改TextBlock前景色、大小的选项,silverlight-4.0,windows-phone-7.1,Silverlight 4.0,Windows Phone 7.1,我是Windowsphone7的新手。我开发了一个示例应用程序,我想提供一个选项来动态更改字体颜色、大小和样式(斜体/粗体)(如RadEditor)。请帮助我如何解决此选项。如果您开发了应用程序MVVM样式,那么这样做并不难。您只需要为每个要动态设置的设置设置一个属性,然后绑定到此属性。创建一个设置视图,可以在其中设置属性,如果更改属性,则使用INotifyPropertyChanged广播属性值已更改,因此绑定到该属性的每个控件都将更改并重新绘制 您找到的用于保存图像的链接看起来不错,但

我是Windowsphone7的新手。我开发了一个示例应用程序,我想提供一个选项来动态更改字体颜色、大小和样式(斜体/粗体)(如RadEditor)。请帮助我如何解决此选项。

如果您开发了应用程序MVVM样式,那么这样做并不难。您只需要为每个要动态设置的设置设置一个属性,然后绑定到此属性。创建一个设置视图,可以在其中设置属性,如果更改属性,则使用INotifyPropertyChanged广播属性值已更改,因此绑定到该属性的每个控件都将更改并重新绘制

您找到的用于保存图像的链接看起来不错,但我做的有点不同,实际上,与CameraCaptureTask相比,您已经获得了一个可写位图图像,您可以这样保存它

要保存图像,请执行以下操作:

private void SaveToIsolatedStorage(WriteableBitmap image, string fileName)
{
    using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (myIsolatedStorage.FileExists(fileName))
        {
            myIsolatedStorage.DeleteFile(fileName);
        }

        using (var stream = myIsolatedStorage.OpenFile(fileName, FileMode.Create))
                    {
                        Extensions.SaveJpeg(image, stream, image.PixelWidth, image.PixelHeight,0, 100);
                    }
    }
}
private WritableBitmap ReadFromIsolatedStorage(string fileName)
{
    WriteableBitmap bitmap = new WriteableBitmap(200,200);
    using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (store.FileExists(fileName))
                    {
                        using (var stream = store.OpenFile(fileName,FileMode.Open))
                        {
                          bitmap.SetSource(stream);

}}                 
    }
    return bitmap;
}
要阅读图像,请执行以下操作:

private void SaveToIsolatedStorage(WriteableBitmap image, string fileName)
{
    using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (myIsolatedStorage.FileExists(fileName))
        {
            myIsolatedStorage.DeleteFile(fileName);
        }

        using (var stream = myIsolatedStorage.OpenFile(fileName, FileMode.Create))
                    {
                        Extensions.SaveJpeg(image, stream, image.PixelWidth, image.PixelHeight,0, 100);
                    }
    }
}
private WritableBitmap ReadFromIsolatedStorage(string fileName)
{
    WriteableBitmap bitmap = new WriteableBitmap(200,200);
    using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (store.FileExists(fileName))
                    {
                        using (var stream = store.OpenFile(fileName,FileMode.Open))
                        {
                          bitmap.SetSource(stream);

}}                 
    }
    return bitmap;
}
我希望这能奏效,因为我是白手起家写的。:)

在ViewModel中,应该有一个WritableBitmap属性,该属性绑定到视图上的图像控件


要使用大量图像并使用它们,您应该阅读更多关于这方面的内容,因为SL图像会占用大量内存,因此您需要在将来以某种方式解决此问题

刚刚编辑并添加了一些带有示例的链接,以帮助您从MVVM和您的问题开始。:)您好,我还有一个问题,我已经从移动摄像头捕获了图片,我想在页面导航后在另一个Xmal文件中显示此图片。是否可能,请帮助我。我尝试使用此链接,但我没有将图像放入另一个Xmal页面。是的,这是可能的,我也这样做了,或者更好地说,我也使用了它。该链接解释了如何将图像保存到应用程序的IsolatedStorage中,以及以后如何检索该图像。但是如果你只需要它一次,那么我认为最好在你的ViewModel中为你的图像设置一个属性,然后从那里检索它。更新了我的答案,希望它对你有用,或者你可以从代码开始。