Boa tarde!
Estou cansado de tentar encontrar uma solução para meu problema.
Criei um controle customizado denominado ButtonImage, onde este exibe uma imagem definido na propriedade ImagePath (DependencyProperty). O problema é que quando foi definir um estilo para o ButtonImage em um dictionary o Visual Studio não lista a propriedade
ImagePath na tag Setter.
Esqueci de comentar que quando eu forço o nome da propriedade, o VS dispara uma exceção de NullReferenceException, como exibido na imagem abaixo.

Fiz algumas alterações para colocar o código pra vocês (Não estranhem, pois o código está em Oxygen)
namespace CasaSoftSig.SL.Resources.Common.Views;
interface
uses
System.Windows,
System.Windows.Controls,
System.Collections.Generic,
System.Text;
type
ButtonImage = public class(Button)
private
class method GetImagePathProperty:DependencyProperty;
method GetImagePath():String;
method SetImagePath(value:String);
protected
public
constructor;
property ImagePath:String read GetImagePath write SetImagePath;
class property ImagePathProperty:DependencyProperty read GetImagePathProperty;
end;
implementation
constructor ButtonImage;
begin
self.DefaultStyleKey := typeOf(ButtonImage);
end;
method ButtonImage.GetImagePath(): String;
begin
exit String(GetValue(ImagePathProperty));
end;
method ButtonImage.SetImagePath(value: String);
begin
SetValue(ImagePathProperty, value);
end;
class method ButtonImage.GetImagePathProperty: DependencyProperty;
begin
exit DependencyProperty.RegisterAttached('ImagePath', typeOf(String), typeOf(ButtonImage), new PropertyMetadata(""));
end;
end.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:local="clr-namespace:Resources.Common.Views;assembly=Resources.Common">
<Style x:Key="StyleDefaultButtonImage"
TargetType="local:ButtonImage">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Image Source="{Binding Path=ImagePath, RelativeSource={RelativeSource AncestorType=local:ButtonImage}}"
Opacity="1"
dxlc:DockLayoutControl.Dock="Left" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StyleButton"
BasedOn="{StaticResource StyleDefaultButtonImage}"
TargetType="local:ButtonImage">
<Setter Property="Height"
Value="16" />
<Setter Property="Width"
Value="16" />
<Setter Property="ImagePath"
Value="somepath" />
</Style>
</ResourceDictionary>
xmlns:csrc="clr-namespace:Resources.Common.Views;assembly=Resources.Common"
<csrc:ButtonImage Style="{StaticResource StyleButton}">
</csrc:ButtonImage>
Estou utilizando: Visual Studio 2010 SP1 Shell e Silverlight 5.
Preciso desta ajuda de vocês.
Obrigado desde já.
Caso alguem o ajudou com respostas, por favor, ajude-o classificando. Obrigado.