如何在外部 XAML-File 中获取 SharpVector 运行
How to get SharpVector running in external XAML-File
我正在尝试将 XAML-文件(某些样式)作为资源包含在我的项目中。
但我希望它们可以互换。所以我不想要生成操作“页面”,而只是将它们复制到输出文件夹并使用那里的样式。
我在 XAML-Files 中使用 SharpVectors。
问题是,如果我加载样式,则会抛出异常:“无法创建未知类型”{http://sharpvectors.codeplex.com/runtime/}EmbeddedBitmapSource”
也许缺少一些参考资料?
XAML-文件:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Aufwerter"
xmlns:c1="clr-namespace:Aufwerter.Converter"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
>
<Style x:Key="RevaluatorBildCashOnly" TargetType="UserControl">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Control">
<Border>
<Grid>
<Image HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" x:Name="IsExpandedPath">
<Image.Source>
<DrawingImage xmlns:svg="http://sharpvectors.codeplex.com/runtime/">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V1957 H575 V0 H0 Z">
<DrawingGroup Opacity="1" Transform="1,0,0,1,6,5">
<DrawingGroup.ClipGeometry>
<RectangleGeometry RadiusX="0" RadiusY="0" Rect="-6,-5,575,1957" />
</DrawingGroup.ClipGeometry>
<DrawingGroup Transform="1,0,0,1,-6,-5" Opacity="1">
<ImageDrawing Rect="0,0,575,1957">
<ImageDrawing.ImageSource>
<svg:EmbeddedBitmapSource Data="iVBORw0KGgoAAAANSUhEUgAAAIwAAAB1CAMAAACrg/ndAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAH1UExURQAAAIeHh4+Pj5eXl5+fn6enp7+/v4aGhqKioouLi5OTk5ubm6Ojo6ampqmpqbG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jx02lKrMICqtrU3Xl1NKlzJLKWMSsX7/ePIOQFFQkUTRMUC1lImbdOuP0FolEUFpdBXJRrd5RRFB3SO5xDKeviCAXkdRy4AiqRHFtfUXErOUEkUD9RSGiIiOJaluTKBZJoEpEzPOYICKoyMg5Nh0iHrgBRD17RMxzNgRJRFCxNYIGyKgpqvUohkRQsTVi8LtXbGByVMyppUuZ1aZyUl5dVPXIyVTErLFxkETDBCVRubpKNFBQxIyNjcGTQYWIoO6Q3OMZFSGRVNRbJILqIniIWb3aOA6qRHFtUSRQq6izTBLFtUlUrs0xGIJcVNuaRLFITZFzbDpEfnET1F4kYvhbQfuK4tYI6t+jzoyaooz506pVqwgqRLUexZAkij0iaOCt6bxJVPXoX8T8ZOVK49RErT0KoFlvLZII+iEx33kas5IjlVhR9Z7kZCyCtLofEPN1/E7mFRQ5SSaKegUlEkUFiaIiqHaSTMppYuKLxHx0OTWYKCLIRSIR1F5viUQiaGARQRA9QszIt5dj3NMtIqi93hLFtUnkpADqFP1elpGvLV26dBlB9yciqP/WBivSxx0zMjo6ah4T2QTQMCKCiq119cg5NgQ97JaRzy/BHw0KokgaXFTrUQyJoF5by8GMjPxq8eLF+KMTjjKVRMXqeqvEqqni5nrm9DuHYB5dtGiReVyUTMypJhJJooIkE0XtQUUSRTGovCTMowuN46CmqF5vgvqtTiT3lKsjKIo+5gyfzy20IchFcW0EvYcHrmYxzYIF8CRRDEmimJFzbIYQERS3VuxI84Ff4o+zuKj31ggaKqNaj0D6bYvF5vE/zJ9PUBGSRE6qQENdAbUegdRYUR5wMHVQ99Yoco5Nb5FIBEn0m2+0x+Lz0OPf/MUTT4g0aE4S9ducWBn1l19/9wsf9A99f3rPyMj/AXJJs/ejg1WMAAAAAElFTkSuQmCC" MimeType="image/png" />
</ImageDrawing.ImageSource>
</ImageDrawing>
</DrawingGroup>
</DrawingGroup>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RevaluatorVideoCashOnly-Cash" TargetType="UserControl">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Control">
<ControlTemplate.Resources>
<Storyboard x:Key="Animation0" BeginTime="00:00:00" RepeatBehavior="Forever" Duration="00:00:02">
<DoubleAnimation From="1" Duration="00:00:01" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="Opacity" To="0" />
</Storyboard>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<Trigger Property="IsVisible" Value="true">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Animation0}" x:Name="Storyboard0" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="Storyboard0"/>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid>
<Viewbox>
<Canvas Name="canvas" Height="450" Width="200">
<UserControl Style="{StaticResource RevaluatorBildCashOnly}" Height="{Binding ElementName=canvas, Path=ActualHeight}" Width="{Binding ElementName=canvas, Path=ActualWidth}" ></UserControl>
<Ellipse x:Name="ellipse0" Width="96" Height="65" Canvas.Left="52" Canvas.Top="242" StrokeThickness="6" Stroke="red" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Top"/>
</Canvas>
</Viewbox>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
添加词典:
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"/Resources/");
foreach (FileInfo item in directoryInfo.GetFiles())
{
ResourceDictionary myResourceDictionary = new ResourceDictionary();
myResourceDictionary.Source = new Uri(item.FullName, UriKind.Absolute);
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
}
查看使用样式的地方:
<Page x:Class="Aufwerter.Views.RevalueManual"
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"
xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:c1="clr-namespace:Aufwerter.Converter"
Title="MainWindow" d:DesignHeight="1200" d:DesignWidth="1920" xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:viewmodels="clr-namespace:Aufwerter.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:RevalueManualViewModel}" Unloaded="Page_Unloaded">
<UserControl Grid.Column="1" HorizontalAlignment="Stretch" Visibility="{Binding IsMediaElementPlaceCardVisible, Converter={StaticResource BoolToVis}}">
<UserControl.Style>
<Binding Converter="{StaticResource VideoSelectorConverter }">
<Binding.Source>
<sys:String>Cash</sys:String>
</Binding.Source>
</Binding>
</UserControl.Style>
</UserControl>
将 returns 样式转换为视图:
return Application.Current.FindResource("RevaluatorVideoCashOnly-Cash") as Style;
我怎样才能让它工作?
您应该在松散(未编译)XAML 中包含实际的命名空间和程序集名称,即将 xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
替换为您使用的每种类型的命名空间映射。
例如,EmbeddedBitmapSource
是:
xmlns:svg="clr-namespace:SharpVectors.Runtime;assembly=SharpVectors.Runtime.Wpf"
我正在尝试将 XAML-文件(某些样式)作为资源包含在我的项目中。 但我希望它们可以互换。所以我不想要生成操作“页面”,而只是将它们复制到输出文件夹并使用那里的样式。 我在 XAML-Files 中使用 SharpVectors。 问题是,如果我加载样式,则会抛出异常:“无法创建未知类型”{http://sharpvectors.codeplex.com/runtime/}EmbeddedBitmapSource” 也许缺少一些参考资料?
XAML-文件:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Aufwerter"
xmlns:c1="clr-namespace:Aufwerter.Converter"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
>
<Style x:Key="RevaluatorBildCashOnly" TargetType="UserControl">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Control">
<Border>
<Grid>
<Image HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" x:Name="IsExpandedPath">
<Image.Source>
<DrawingImage xmlns:svg="http://sharpvectors.codeplex.com/runtime/">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V1957 H575 V0 H0 Z">
<DrawingGroup Opacity="1" Transform="1,0,0,1,6,5">
<DrawingGroup.ClipGeometry>
<RectangleGeometry RadiusX="0" RadiusY="0" Rect="-6,-5,575,1957" />
</DrawingGroup.ClipGeometry>
<DrawingGroup Transform="1,0,0,1,-6,-5" Opacity="1">
<ImageDrawing Rect="0,0,575,1957">
<ImageDrawing.ImageSource>
<svg:EmbeddedBitmapSource Data="iVBORw0KGgoAAAANSUhEUgAAAIwAAAB1CAMAAACrg/ndAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAH1UExURQAAAIeHh4+Pj5eXl5+fn6enp7+/v4aGhqKioouLi5OTk5ubm6Ojo6ampqmpqbGxsbe3t7+/v4eHh42NjY+Pj5qamqqqqoeHh4mJiZOTk5mZmZubm4mJiY+Pj5OTk52dnYyMjJCQkJSUlJeXl5ycnMTExIaGhqurq6ysrIeHh4iIiJOTk5aWlq+vr7q6usbGxomJiYuLi46Ojpqamp2dnZ6enqOjo6ampoqKioyMjJCQkJaWlpiYmJqampycnJ6enqGhoaSkpKenp6ysrK6urrS0tMjIyMzMzIeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKS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ILqIniIWb3aOA6qRHFtUSRQq6izTBLFtUlUrs0xGIJcVNuaRLFITZFzbDpEfnET1F4kYvhbQfuK4tYI6t+jzoyaooz506pVqwgqRLUexZAkij0iaOCt6bxJVPXoX8T8ZOVK49RErT0KoFlvLZII+iEx33kas5IjlVhR9Z7kZCyCtLofEPN1/E7mFRQ5SSaKegUlEkUFiaIiqHaSTMppYuKLxHx0OTWYKCLIRSIR1F5viUQiaGARQRA9QszIt5dj3NMtIqi93hLFtUnkpADqFP1elpGvLV26dBlB9yciqP/WBivSxx0zMjo6ah4T2QTQMCKCiq119cg5NgQ97JaRzy/BHw0KokgaXFTrUQyJoF5by8GMjPxq8eLF+KMTjjKVRMXqeqvEqqni5nrm9DuHYB5dtGiReVyUTMypJhJJooIkE0XtQUUSRTGovCTMowuN46CmqF5vgvqtTiT3lKsjKIo+5gyfzy20IchFcW0EvYcHrmYxzYIF8CRRDEmimJFzbIYQERS3VuxI84Ff4o+zuKj31ggaKqNaj0D6bYvF5vE/zJ9PUBGSRE6qQENdAbUegdRYUR5wMHVQ99Yoco5Nb5FIBEn0m2+0x+Lz0OPf/MUTT4g0aE4S9ducWBn1l19/9wsf9A99f3rPyMj/AXJJs/ejg1WMAAAAAElFTkSuQmCC" MimeType="image/png" />
</ImageDrawing.ImageSource>
</ImageDrawing>
</DrawingGroup>
</DrawingGroup>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RevaluatorVideoCashOnly-Cash" TargetType="UserControl">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Control">
<ControlTemplate.Resources>
<Storyboard x:Key="Animation0" BeginTime="00:00:00" RepeatBehavior="Forever" Duration="00:00:02">
<DoubleAnimation From="1" Duration="00:00:01" Storyboard.TargetName="ellipse0" Storyboard.TargetProperty="Opacity" To="0" />
</Storyboard>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<Trigger Property="IsVisible" Value="true">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Animation0}" x:Name="Storyboard0" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="Storyboard0"/>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid>
<Viewbox>
<Canvas Name="canvas" Height="450" Width="200">
<UserControl Style="{StaticResource RevaluatorBildCashOnly}" Height="{Binding ElementName=canvas, Path=ActualHeight}" Width="{Binding ElementName=canvas, Path=ActualWidth}" ></UserControl>
<Ellipse x:Name="ellipse0" Width="96" Height="65" Canvas.Left="52" Canvas.Top="242" StrokeThickness="6" Stroke="red" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Top"/>
</Canvas>
</Viewbox>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
添加词典:
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"/Resources/");
foreach (FileInfo item in directoryInfo.GetFiles())
{
ResourceDictionary myResourceDictionary = new ResourceDictionary();
myResourceDictionary.Source = new Uri(item.FullName, UriKind.Absolute);
Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
}
查看使用样式的地方:
<Page x:Class="Aufwerter.Views.RevalueManual"
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"
xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:c1="clr-namespace:Aufwerter.Converter"
Title="MainWindow" d:DesignHeight="1200" d:DesignWidth="1920" xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:viewmodels="clr-namespace:Aufwerter.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:RevalueManualViewModel}" Unloaded="Page_Unloaded">
<UserControl Grid.Column="1" HorizontalAlignment="Stretch" Visibility="{Binding IsMediaElementPlaceCardVisible, Converter={StaticResource BoolToVis}}">
<UserControl.Style>
<Binding Converter="{StaticResource VideoSelectorConverter }">
<Binding.Source>
<sys:String>Cash</sys:String>
</Binding.Source>
</Binding>
</UserControl.Style>
</UserControl>
将 returns 样式转换为视图:
return Application.Current.FindResource("RevaluatorVideoCashOnly-Cash") as Style;
我怎样才能让它工作?
您应该在松散(未编译)XAML 中包含实际的命名空间和程序集名称,即将 xmlns:svg="http://sharpvectors.codeplex.com/runtime/"
替换为您使用的每种类型的命名空间映射。
例如,EmbeddedBitmapSource
是:
xmlns:svg="clr-namespace:SharpVectors.Runtime;assembly=SharpVectors.Runtime.Wpf"