Style addin

Mar 19, 2008 at 7:43 AM
my addin is control object. i want to design the addin with style tag in xaml. how to do?

xmlns:addin="clr-namespace:HostViews;assembly=HostViews"
...
<Window.Resources>
<Style TargetType="addin:WPFAddInHostView">
<Setter Property="Opacity" Value="0.5"/>
</Style>
</Window.Resources>
<Grid Name="grid">
<Canvas Name="AdContent"/>
</Grid>



public Window1()
{
InitializeComponent();
LoadAddin();
}
void LoadAddin()
{
String path = Environment.CurrentDirectory;
String[] warnings = AddInStore.Rebuild(path);
IList<AddInToken> tokens = AddInStore.FindAddIns(typeof(HostViews.WPFAddInHostView), path);
addins = new List<HostViews.WPFAddInHostView>();

foreach (AddInToken token in tokens)
{
HostViews.WPFAddInHostView c;

if (token.ToString().Contains("Image"))
{
c = token.Activate<HostViews.WPFAddInHostView>(AddInSecurityLevel.FullTrust);
c.ImageSource = "E:\\imageData\\D0002698512";

addins.Add(c);
AdContent.Children.Add(c);

}
}
}

in above code, my style doesnt work,why?
Mar 27, 2008 at 11:36 PM
The style from the host is not automatically propegated over to the add-in. If you want to define a style for use by the add-in you should define it as part of the add-in view, and not inside the host application.

Transparency in particular will not work because windows doesn't support transparency across HWNDS (which WPF uses to parent WPF controls across AppDomain boundaries), but other style elements are valid and can be defined on the add-in side view.

--Jesse