I have a number of UserControl classes:
- DataTypeWholeNumber
- DataTypeLine
- DataTypeDate
- DateTypeDuration
- etc.
They all inherit from a plain C# class which inherits from UserControl which has no XAML attached to it. I had to do it this way since I was getting errors saying that XAML could not be inherited.
The problem is that the XAML for each of these UserControls is basically the same, so I would like to find some way to at least emulate XAML inheritance so that I don't have to repeat this code for 20 different classes:
<dataTypes:BaseDataType x:Class="TestDependencyProperty827.DataTypes.DataTypeLine"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dataTypes="clr-namespace:TestDependencyProperty827.DataTypes">
<StackPanel Margin="{Binding Margin}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding LabelWidth}"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="{Binding Label}" FontSize="14"/>
<TextBlock FontSize="14" Text=":"/>
</StackPanel>
<TextBox Grid.Column="1" FontSize="12" HorizontalAlignment="Left"
Text="{Binding Text}"
Width="{Binding Width}"/>
</Grid>
</StackPanel>
</dataTypes:BaseDataType>
Has anyone run into this problem and found a solution to it?