找不到资源。 wpf用户控件中的错误

时间:2014-03-27 04:46:41

标签: wpf user-controls

<Window x:Class="Hotel_WPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="" Height="644" Width="1369" Icon="/Hotel_WPF;component/Resources/DCE.ico" 
        ResizeMode="CanResize" ShowInTaskbar="False" Topmost="False" 
        WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow" 
        BorderBrush="Black" FontFamily="Calibri" AllowsTransparency="False" 
        BorderThickness="1" WindowState="Maximized" 
        xmlns:my="clr-namespace:DC.CommandButton;assembly=DC.CommandButton">
    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFEFEDE6" Offset="0.006" />
            <GradientStop Color="#FF174EB8" Offset="1" />
            <GradientStop Color="#FFC7D7FC" Offset="0.503" />
        </LinearGradientBrush>
    </Window.Background>
    <Grid Focusable="False" ShowGridLines="True" Background="{x:Null}">
        <Grid.OpacityMask>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black" Offset="0" />
                <GradientStop Color="White" Offset="1" />
            </LinearGradientBrush>
        </Grid.OpacityMask>
        <my:DcButton Height="40" HorizontalAlignment="Left" Margin="196,361,0,0" Name="dcButton1" VerticalAlignment="Top" Width="153" />
    </Grid>
</Window>

我已将MouseEnter,MouseLeave事件写入按钮。它在测试项目中运行良好,但在其他解决方案中没有。请帮忙。

1 个答案:

答案 0 :(得分:0)

再次检查

xmlns:my="clr-namespace:DC.CommandButton;assembly=DC.CommandButton"

不应该是这样:(假设您的命名空间是DC)

xmlns:my="clr-namespace:DC;assembly=DC.CommandButton"