【发布时间】:2015-06-29 11:05:26
【问题描述】:
所以下面的图片说明了一切。 WPF 无法定位 一些 xaml 文件。我试过移动它们,但无济于事。它们都将构建操作设置为页面,并将自定义工具设置为 MSBuild:Compile。不知道我在这里错过了什么。
编辑
根据要求,这里有两个示例 xaml 文件。其中一个有效,另一个无效。
GroupBox.xaml(工作之一)
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Shared.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- SimpleStyles: GroupBox -->
<Style TargetType="GroupBox">
<Setter Property="Control.Foreground" Value="#4C4C4C"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupBox">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0"
Background="{StaticResource LightBrush}"
BorderBrush="{StaticResource NormalBorderBrush}"
BorderThickness="1"
CornerRadius="2,2,0,0" >
<ContentPresenter Margin="4"
HorizontalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True" />
</Border>
<Border Grid.Row="1"
Background="{StaticResource WindowBackgroundBrush}"
BorderBrush="{StaticResource SolidBorderBrush}"
BorderThickness="1,0,1,1"
CornerRadius="0,0,2,2" >
<ContentPresenter Margin="4" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Toolbox.xaml(不起作用)
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:DiagramDesigner">
<Style TargetType="{x:Type s:Toolbox}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:Toolbox}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel Margin="0,5,0,5"
ItemHeight="{Binding Path=ItemSize.Height, RelativeSource={RelativeSource AncestorType=s:Toolbox}}"
ItemWidth="{Binding Path=ItemSize.Width, RelativeSource={RelativeSource AncestorType=s:Toolbox}}"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
编辑 2
这可能看起来很疯狂,但是将 x:Class="DiagramDesigner.App" 更改为 x:Class="App" 为我修复了所有错误。看起来 VB.NET 不希望我在该属性中指定命名空间。
【问题讨论】:
-
假设您已经完成了清理和重建?这总是用 WPF 为我解决它
-
@Nico:这对我不起作用。我也重新启动了VS。需要注意的是,问题仅限于一些而不是所有文件。
-
您使用的是网络共享还是外部存储?
-
工作文件和非工作文件之一的内容是什么?
-
请在示例项目中一一尝试资源字典。检查是否正常工作。
标签: .net wpf xaml resourcedictionary