在UserControl中找不到附加属性Resources

时间:2011-04-28 09:46:57

标签: c# wpf wpftoolkit

在为我的用户控件添加资源期间,我收到上述错误。可能是什么问题?

<UserControl x:Class="PartitionManager.DocStorageView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:WpfToolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="800">
    <UserControl.Resources></UserControl.Resources>
    <WpfToolkit:DataGrid
        ItemsSource="{Binding Path=DocStorageInfos}"
        HorizontalScrollBarVisibility="Auto"  SelectionMode="Extended"
        CanUserAddRows="False" CanUserDeleteRows="False"
        CanUserResizeRows="False" CanUserSortColumns="False"
        AutoGenerateColumns="False" MaxWidth="750">
        <WpfToolkit:DataGrid.Columns>
            <WpfToolkit:DataGridCheckBoxColumn
                Header="Select"
                Binding="{Binding Path=IsSelected}"/>
            <WpfToolkit:DataGridTextColumn
                Header="InterestingName" 
                Binding="{Binding Path=InterestingName}"/>
        </WpfToolkit:DataGrid.Columns>
    </WpfToolkit:DataGrid>
</UserControl>

1 个答案:

答案 0 :(得分:1)

您是否可能在代码隐藏中搞乱继承?

您的类需要从UserControl继承:

 public partial class DocStorageView : UserControl
 { /*...*/ }