以下のXAMLは変わる唯一の事は、それがホストすることをユーザーコントロールである私は、いくつかのプレゼンテーションで使用していますウィンドウのためです:WPFウィンドウを再利用しようとしている
<Window x:Class="Smack.ConstructionAdmin.Presentation.Wpf.Views.Admin.Employees.EmployeeShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Smack.ConstructionAdmin.Presentation.Wpf.Views.Admin.Employees"
xmlns:s="clr-namespace:Smack.ConstructionAdmin.Presentation.Wpf"
xmlns:cmdRef="clr-namespace:Smack.Core.Presentation.Wpf.ViewModels.Commands.Reference;assembly=Smack.Core.Presentation.Wpf"
Background="{DynamicResource WaveWindowBackground}"
Title="{Binding Source={x:Static s:Strings.AppName}}"
Icon="pack://application:,,,/Smack.ConstructionAdmin.Presentation.Wpf;component/Images/Time-Machine_16.png"
FontFamily="Arial"
WindowStartupLocation="CenterScreen" Width="750" Height="600"
>
<DockPanel>
<local:EmployeeShellUserControl DataContext="{Binding}" />
</DockPanel>
<Window.InputBindings>
<cmdRef:KeyBindingEx CommandReference="{Binding AddCommand}"/>
<cmdRef:KeyBindingEx CommandReference="{Binding EditCommand}"/>
<cmdRef:KeyBindingEx CommandReference="{Binding DeleteCommand}"/>
</Window.InputBindings>
</Window>
だから、再利用しても意味がいるようだが、何とか変わらない部分。ここではスタイルでそうすることで私の最初の試みは、次のとおりです。
<Style x:Key="MyWindowStyle" TargetType="{x:Type Window}">
<Setter Property="Background" Value="{DynamicResource WaveWindowBackground}"></Setter>
<Setter Property="FontFamily" Value="Arial"></Setter>
<Setter Property="Height" Value="600"></Setter>
<Setter Property="Width" Value="750"></Setter>
<Setter Property="Title" Value="{Binding AppName}"></Setter>
<Setter Property="Icon" Value="{Binding IconUri}"></Setter>
</Style>
痛みは
- を指して、私はInputBindingsを作る方法を見ないWindowStartupLocation
- のためのプロパティのセッターを見つけることができませんでしたスタイルの一部
私は使用する必要があるスタイルやアプローチを使用していますか?上記のプロパティはどのように設定できますか?
乾杯。
Berryl
これは完璧だと思います!しかし、あなたが何を意味しているのか分からない - あなたはいくつかのコードやxamlをより良く説明するために傷つけることができるだろうか? – Berryl
@Berryl:サンプルを追加しました。 – Jon
そのようにShellViewをそのままにしてインスタンス化し、コンテンツを設定しますか?既存のUserControlを置き換える部分はどのようにContentになるのでしょうか、それともContentプロパティの定義ですか? – Berryl