I have a page which contains an overridable property "FileName". I want to create the whole page and inherit from them to have same pages but with different filename.
Is this possible?
Main page 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>
Codebehind:
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
Second Page XAML ??:
<!-- -->
Second Page Codebehind:
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
I was doing something very similar to this when I was building a wizard in WPF. The way I went about doing it was by creating a class (let's say "MyPage") that simply extends page and adds the FileName property to it. Then, when you want to use MyPage, declare it in the XAML as such. This way your XAML will look like more or less like:
<mynamespace:MyPage
xmlns:mynamespace="clr-namespace:PathOfNamespace"
FileName="MyFileName.file">
<some more XAML>
</mynamespace:MyPage>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With