xamlwriter

Creating FlowDocument on BackgroundWorker thread

和自甴很熟 提交于 2019-12-11 12:59:22
问题 I have the need to generate dynamically generate a FlowDocument from a large set of data. Because the process takes several minutes, I'd like to perform the operation on a background thread rather than have the UI hang. However, I can't generate the FlowDocument on a non-UI thread otherwise attempts to insert rectangles and images cause run-time errors complaining that it's not STA thread. There are a couple of threads on StackOverflow which seem to involve the same problem I'm having:

How to prevent XamlWriter.Save from serializing the BaseUri property?

五迷三道 提交于 2019-12-10 09:19:15
问题 I'm making a theme editor for a WPF application. I generate XAML files dynamically, then I compile them into a DLL that is used by the application. The code used to generate the XAML files goes along those lines: var dictionary = new ResourceDictionary(); ... dictionary.Add(key, new BitmapImage { UriSource = new Uri(relativePath, UriKind.Relative) }); ... XamlWriter.Save(dictionary, "myDictionary.xaml"); My problem is that XamlWriter.Save also serializes the BaseUri property: <BitmapImage

TFS 2010: Why is it not possible to deserialize a Dictionary<string, object> with XamlWriter.Save when I can use XamlReader for deserializing

拟墨画扇 提交于 2019-12-08 17:27:55
问题 public static string GetXml(Dictionary<string, object> parameters) { return XamlWriter.Save(parameters); } The above statement returns a NotSupportedException . The strange thing is that I can use the XamlReader to serialize a dictionary. public static Dictionary<string, object> GetParameters(IBuildDetail buildDetail, string buildDefinition) { var tfsProject = buildDetail.BuildDefinition.TeamProject; var buildServer = buildDetail.BuildServer; var buildDef = buildServer.GetBuildDefinition