开发者

WPF Issue with TemplateBinding

开发者 https://www.devze.com 2023-04-11 13:49 出处:网络
I am using VS2008.I have this class [System.Windows.Markup.ContentProperty(\"Child\")] public class CaptionedBox : Control

I am using VS2008. I have this class

[System.Windows.Markup.ContentProperty("Child")]
public class CaptionedBox : Control
{
    static CaptionedBox()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(CaptionedBox), 
            new FrameworkPropertyMetadata(typeof(CaptionedBox)));
    }

    public static readonly DependencyProperty ShadeVisibilityProperty = 
        DependencyProperty.Register(
        "ShadeVisibility", typeof(Visibility), typeof(CaptionedBox), new 
         PropertyMetadata(Visibility.Hidden));
}

and this code in a ResourceDictionary (in a file called Generic.xaml)

<ControlTemplate TargetType="{x:Type wft:CaptionedBox}">
    <Grid>
        ...
        <Rectangle Fill="#44000000" Visibility="{TemplateBinding ShadeVisibility}"/>
    </Grid>
</ControlTemplate>

There are no errors, no problems, I use this CaptionedBox all over the place.

I have another XAML page in the same project that references this ResourceDictionary with Source="../Themes/G开发者_开发知识库eneric.xaml". When I open that page, it says "The resource dictionary XAML file has errors and cannot be loaded." It is referring to the Generic.XAML at that point. If I double click on the error message, even with Generic.XAML open in VS 2008, I get a different tab for what looks like a different Generic.xaml, except that the contents are identical and if I copy the full path for each of the tabs, I see this:

C:\Source\LyonsForge\root\PumpServicing\branches\PSRT_1_0_2\Code\Bench\Controls\Wizard..\Themes\Generic.xaml C:\Source\LyonsForge\root\PumpServicing\branches\PSRT_1_0_2\Code\Bench\Controls\Themes\Generic.xaml

which, although a bit awkward, are the same path.

Any clues?


Have you already make your generic.xaml to be copy local? Also don't forget to set the option on the property of the file: "Copy to output directory" to "Copy always", because the generic.xaml is not meant to be compiled.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号