样式边框和标题栏导致NullReferenceException

时间:2015-07-23 12:16:40

标签: wpf xaml styles

我想更改form边框和标题栏以及fount this解决方案。 所以在将此添加到我的XAML(我在第一个答案中使用第一个解决方案)后,我的应用程序正在运行,我可以看到Style已更改但几秒后我可以在设计器中看到此异常:

enter image description here

我的应用程序仍在运行并显示新样式,但这种情况一次又一次地发生,我尝试删除并多次添加更改,但此错误仍会在一段时间后跳转。     更新

这是添加到XAML的代码:

<Window x:Class="CSharpWPF.MainWindow" 
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" >
    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="{Binding ActualHeight,ElementName=titlebar}"/>
    </WindowChrome.WindowChrome>
    <DockPanel LastChildFill="True">
        <Border Background="LightBlue" DockPanel.Dock="Top" Height="25" x:Name="titlebar">
            <TextBlock Text="{Binding Title, RelativeSource={RelativeSource FindAncestor,AncestorType=Window},FallbackValue=Title}" 
                       Margin="10,0,0,0"
                       VerticalAlignment="Center">
                <TextBlock.Effect>
                    <DropShadowEffect Color="White" ShadowDepth="3"/>
                </TextBlock.Effect>
            </TextBlock>
        </Border>
        <Border BorderBrush="LightGray" BorderThickness="1" Padding="4">
            <TextBlock Text="Window content"/>
        </Border>
    </DockPanel>
</Window>

0 个答案:

没有答案
相关问题