2011-08-09 20 views
3

私は、オーバーライド可能なプロパティ "FileName"を含むページを持っています。 私はページ全体を作成し、同じページを持つがファイル名が異なるように継承したい。WPFページから継承

これは可能ですか?

メインページXAML:

<Page x:Class="Batcher_File" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:my="clr-namespace:TB_InstallSystem" 
     DataContext="{Binding RelativeSource={RelativeSource Self}}" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="600" 
     Title="Batcher"> 
    </Page> 

分離コード:

Class Batcher_File 
    Private _fiBatch As New IO.FileInfo(TB.SystemMain.AppPath & "myfile.xml") 
    Public Overridable Property fiBatch As IO.FileInfo 
     Get 
      Return _fiBatch 
     End Get 
     Set(value As IO.FileInfo) 
      _fiBatch = value 
     End Set 
    End Property 
End Class 

2番目のページXAML ??:

<!-- --> 

2番目のページ分離コード:

Public Class Batc_After 
    Inherits Batcher_Filer 

    Private _fiBatch As New IO.FileInfo(TB.SystemMain.AppPath & "batch_after.xml") 
    Public Overrides Property fiBatch As IO.FileInfo 
     Get 
      Return _fiBatch 
     End Get 
     Set(value As IO.FileInfo) 
      _fiBatch = value 
     End Set 
    End Property 




End Class 

答えて

1

私はWPFでウィザードを構築していたときに、これと非常によく似たことをしていました。私がそれをやり遂げたのは、単純にページを拡張し、それにFileNameというプロパティを追加するクラス( "MyPage"と言う)を作成することでした。次に、MyPageを使用する場合は、それをXAMLに宣言します。このようにして、XAMLは多かれ少なかれ次のようになります。

<mynamespace:MyPage 
    xmlns:mynamespace="clr-namespace:PathOfNamespace" 
    FileName="MyFileName.file"> 
    <some more XAML> 
</mynamespace:MyPage>