App.xaml中的WPF全局资源
我已经创建了一个自定义Treeview控件,正在尝试从同一项目的另一个页面访问该控件的HierarchycalDataTemplate资源 我的this.sceneTemplate属性为空。我已经遍历了字典中的所有对象,它确实存在 如何访问此模板 谢谢 App.xamlApp.xaml中的WPF全局资源,wpf,xaml,resources,Wpf,Xaml,Resources,我已经创建了一个自定义Treeview控件,正在尝试从同一项目的另一个页面访问该控件的HierarchycalDataTemplate资源 我的this.sceneTemplate属性为空。我已经遍历了字典中的所有对象,它确实存在 如何访问此模板 谢谢 App.xaml <Application x:Class="Foo.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:
<Application x:Class="Foo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
DispatcherUnhandledException="App_DispatcherUnhandledException">
<Application.Resources>
<ResourceDictionary>
<!--Merge the global resource to the application-->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Global.xaml"/>
<ResourceDictionary Source="Resources/Scrollbar.xaml"/>
<ResourceDictionary Source="/Controls/TreeView/Themes/Generic.xaml"/>
<ResourceDictionary Source="/Controls/ListButton/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
场景层次数据模板
<HierarchicalDataTemplate x:Key="Scene" ItemsSource="{Binding XPath=Level}"
ItemContainerStyle="{StaticResource RadTreeViewItemStyleSub1}"
ItemTemplate="{StaticResource Procedure}"
>
<Border>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label VerticalContentAlignment="Center"
BorderThickness="0"
BorderBrush="Transparent"
Foreground="{StaticResource ListItemUnHighlight}"
FontSize="24"
Tag="{Binding XPath=@name}"
MinHeight="55"
Cursor="Hand"
FontFamily="Arial"
KeyboardNavigation.TabNavigation="None"
Name="SubItem" >
<Label.ContextMenu>
<ContextMenu Name="editMenu">
<MenuItem Header="Edit"/>
</ContextMenu>
</Label.ContextMenu>
<TextBlock Text="{Binding XPath=@name}" VerticalAlignment="Center" TextWrapping="Wrap"></TextBlock>
</Label>
</Grid>
</Border>
</HierarchicalDataTemplate>
更新-答案
我们的程序有一个breadcrumb控件,通过使用页面列表来导航。此页面列表是在运行InitializeComponent之前在启动屏幕中添加的。我将其移到页面列表代码上方,现在可以找到App.xaml中的所有内容。我们的程序有一个breadcrumb控件,它通过使用页面列表来导航。此页面列表是在运行InitializeComponent之前在启动屏幕中添加的。我将其移到页面列表代码上方,现在可以找到App.xaml中的所有内容。我们的程序有一个breadcrumb控件,它通过使用页面列表来导航。此页面列表是在运行InitializeComponent之前在启动屏幕中添加的。我将其移到页面列表代码上方,现在可以找到App.xaml中的所有内容。在应用程序启动事件中,您能否迭代所有资源字典并查找其中的特定对象,以验证它是否加载了正确的字典?我已验证它是否位于正确的资源字典中。@Ryan,这将是值得张贴您的更新作为一个实际的答案,然后在几天内接受它。这将问题标记为“已回答”。在应用程序启动事件中,您是否可以迭代所有资源字典并查找其中的特定对象,以验证它是否加载了正确的字典?我已验证它是否位于正确的资源字典中。@Ryan,值得将您的更新作为实际答案发布,然后在几天后接受它。这表明这个问题是“已回答的”。
<HierarchicalDataTemplate x:Key="Scene" ItemsSource="{Binding XPath=Level}"
ItemContainerStyle="{StaticResource RadTreeViewItemStyleSub1}"
ItemTemplate="{StaticResource Procedure}"
>
<Border>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label VerticalContentAlignment="Center"
BorderThickness="0"
BorderBrush="Transparent"
Foreground="{StaticResource ListItemUnHighlight}"
FontSize="24"
Tag="{Binding XPath=@name}"
MinHeight="55"
Cursor="Hand"
FontFamily="Arial"
KeyboardNavigation.TabNavigation="None"
Name="SubItem" >
<Label.ContextMenu>
<ContextMenu Name="editMenu">
<MenuItem Header="Edit"/>
</ContextMenu>
</Label.ContextMenu>
<TextBlock Text="{Binding XPath=@name}" VerticalAlignment="Center" TextWrapping="Wrap"></TextBlock>
</Label>
</Grid>
</Border>
</HierarchicalDataTemplate>