私はMainWindowに簡単なusercontrolを持っています。私は簡単にprotableです簡単なウィンドウテンプレートを作成しようとしています。私はusercontrolを持っていますこれはこれまでのところ私の目的を果たしているようです...ちょっと...UserControlのWindowStyleとAllowTransparencyを設定する
私はAllowControlsとWindowStyleをusercontrolに設定すると、プロジェクトは正常にコンパイルされますが、コントロールのMainWindowではObject Not Setインスタンスに...コントロール全体に下線が引かれています。私がMainWindowを設定した場合は、すべていいです。私はこれで生きることができますが、望む結果は生きられません。
XAML
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cntl="clr-namespace:Rtg"
Title="MainWindow" Height="400" Width="525">
<!-- if I add windowstyle and allowtransparency here all good -->
<Grid>
<cntl:test1 WinTitle="test window framing">
<cntl:test1.PlaceHolder1>
<Grid Background="Orange">
<TextBox BorderBrush="Transparent" Text="Content in placehoder:" Height="35" Width="175" Margin="0,10,270,0" Background="Transparent" FontSize="16" ></TextBox>
<Button Width="100" Height="35" Content="click me" FontSize="16"></Button>
</Grid>
</cntl:test1.PlaceHolder1>
</cntl:test1>
</Grid>
</Window>
C#
public test1() {
Window win = Application.Current.MainWindow;
win.WindowStyle = System.Windows.WindowStyle.None;
win.AllowsTransparency = true;
InitializeComponent();
ctrTest2.Title = WinTitle;
}
はウェブWPFはややかなり新しい私にある最後の15年間開発してき。
これはWPFの通常の動作ですか? これはどこかにありますか?これで、私はusercotrolのウィンドウのプロパティを設定できますか?
前後は関係ありません。私は同じエラーが発生します。 MainWindowがnullだった場合にのみ問題になると思います。しかし、コンストラクタは既に呼び出されており、MainWindowはInitializingのプロセス中です。 – Mike
それは本当に奇妙です、私は実際にデモプロジェクトを作成し、試して、それは私のために正常に働いた。たぶんviewmodelでそれを試してプロパティとしてバインドしてください。 –