Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Custom Control - Designer looks fine, but I get a runtime issue
    text
    copied!<p>MainWindow.xaml</p> <pre><code>&lt;Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:MyStuff;assembly=MyStuff" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;TabControl Margin="5"&gt; &lt;TabItem Header="Start Page" /&gt; &lt;my:XTabItem Header="Tab 1" Image="Resources/icon1.png" /&gt; &lt;/TabControl&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Generic.xaml</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyStuff" &gt; &lt;!-- XTabItem --&gt; &lt;Style TargetType="{x:Type local:XTabItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type local:XTabItem}"&gt; &lt;Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="{Binding Path=Image, RelativeSource={RelativeSource TemplatedParent}}" Stretch="UniformToFill" MaxHeight="24" /&gt; &lt;TextBlock Text="{TemplateBinding Header}" /&gt; &lt;Button Content="X" /&gt; &lt;/StackPanel&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>XTabItem.cs</p> <pre><code>using System; using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace MyStuff { public class XTabItem : TabItem { #region Dependency Properties public static readonly DependencyProperty ImageProperty; #endregion #region Constructors / Initializer static XTabItem() { //Initialize the control as "lookless". DefaultStyleKeyProperty.OverrideMetadata(typeof(XTabItem), new FrameworkPropertyMetadata(typeof(XTabItem))); //Setup the dependency properties. ImageProperty = DependencyProperty.Register("Image", typeof(ImageSource), typeof(XTabItem), new UIPropertyMetadata(null)); } #endregion #region Custom Control Properties (Image) /// &lt;summary&gt; /// The image (icon) displayed by inside the tab header. /// &lt;/summary&gt; /// &lt;remarks&gt;The image is specified in XAML as an absolute or relative path.&lt;/remarks&gt; [Description("The image displayed by the button"), Category("Optional Properties")] public ImageSource Image { get { return (ImageSource)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } } #endregion } } </code></pre> <p>Exception at line #9 () : XamlParseException : 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '9' and line position '27'.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload