使用建立自定義控制元件(不是用戶控制元件)的方法建了一個自定義的windows
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ExControls">
<Style TargetType="{x:Type local:ExWindow}">
<Setter Property="Foreground" Value="https://bbs.csdn.net/topics/{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<!--<Setter Property="Background" Value="https://bbs.csdn.net/topics/{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>-->
<Setter Property="AllowsTransparency" Value="https://bbs.csdn.net/topics/True"/>
<Setter Property="Background" Value="https://bbs.csdn.net/topics/Transparent"/>
<Setter Property="WindowStyle" Value="https://bbs.csdn.net/topics/None"/>
<Setter Property="OpacityMask" Value="https://bbs.csdn.net/topics/White"/>
<Setter Property="TextOptions.TextFormattingMode" Value="https://bbs.csdn.net/topics/Display"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ExWindow}">
<Border x:Name="formBorder" BorderThickness="2" CornerRadius="5" Background="{TemplateBinding WindowBackground}" BorderBrush="{TemplateBinding WindowBorderBrush}">
<AdornerDecorator Grid.Row="1">
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}"/>
</AdornerDecorator>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
然后,定義了一下類
public class ExWindow : Window
{
static ExingWindow()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ExWindow), new FrameworkPropertyMetadata(typeof(ExWindow)));
}
/// <summary>
/// 建構式
/// </summary>
public ExingWindow()
{
this.WindowStyle = WindowStyle.None; // 加上這句也不行,在設計時表單的WindowStyle不變,只有在運行時才變
}
}
最后在Generic.xaml檔案中參考了該表單
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/ExControls;component/Controls/ExWindow.xaml"/>
</ResourceDictionary.MergedDictionaries>
最后用到專案中去的時候,在設計時無法預覽。

但是在運行時有效,請問大家誰見過這種現象?都是怎么解決的呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/239737.html
上一篇:glDrawTransformFeedbackStream的資料來源問題
下一篇:求大佬幫幫忙
