I'm writing a .NET AddIn that uses WPF for its user interface. Borrowing from the WPF examples delivered with the SDK, I am able to display a XAML form.
The example uses class WPFInteropHelper. WPFInteropHelper.IconName presumably does what it says on the tin, but I can't get it to work. In the absence of documentation, I've tried different approaches.
WPFInteropHelper
WPFInteropHelper.IconName
WPFInteropHelper.IconName expects what:
Should the icon be:
.bmp
.ico
Does it look for the icon>
The example has this:
m_wndHelper.IconName = "DesignModel";
However, I can't see an icon name DesignModel in the app's resource.
Hi Jon Summers,
The base class of WPFInteropHelper is Bentley.MstnPlatformNet.GUI that provides GuiInteropHelper class and respective SetIcon("iconname") method. Only a valid IconType (wraps System.Type.GetType()) is permitted for the icon instance. See Images and Icons for Visual Studio (Topic: "File Types". Current Icon Types of: png, bmp, ico, XAML, svg, 24bit gif).
Window.Icon can be used in WPF content targets: Assembly icons and Window icons.
I presume w/o looking if not providing direct pathing information and using icon name alone, the paths searched would be within the owning/same assembly resources first, the folder of that assembly, then OS system paths respectively. If needed we can try to identify more location details or documentation if available, or draw conclusions using Microsoft Process Monitor for empirical evidence.
HTH,Bob
Robert Hook said:I presume w/o looking if not providing direct pathing information and using icon name alone, the paths searched would be within the owning/same assembly resources
In the example we have m_wndHelper.IconName = "DesignModel"; but I don't see a DesignModel icon in that example's resource. But when I run the demo I can see what might be that icon...
Regards, Jon Summers LA Solutions
Sorry for the brevity and HTH...Short answer is the "DesignModel" icon is being obtained from DgnViewIcons.rsc located in the MicroStation product root folder.
Bob
Robert Hook said:the "DesignModel" icon is being obtained from DgnViewIcons.rsc located in the MicroStation product root folder
Thanks: so the WPFInteropHelper is designed to look in that location by default? How do I instruct it to look elsewhere?
There's also a WPFInteropHelper.SetIcon(string iconName) method, which seems belt-and-braces.
WPFInteropHelper.SetIcon(string iconName)
Hi Jon,I would like to know exactly the same thing.Would also like to include own .ico file in the top left of the window form.
What works quite easily as a standard WPF app via XAML code does not work as a window in a Microstation.AddIn.
<Window x:Class="WpfAppTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfAppTest" Title="WpfAppTest" ResizeMode="NoResize" mc:Ignorable="d" Icon="Logo_Editor.ico" SizeToContent="WidthAndHeight"> <Canvas Height="80" Width="400"> <TextBox Height="24" Width="380" Text="" Canvas.Left="10" Canvas.Top="10"/> <ComboBox Height="18" Width="170" Canvas.Left="10" Canvas.Top="46" /> <Button Height="24" Width="90" Content="Schrift setzen" Canvas.Left="185" Canvas.Top="46"/> <TextBox Height="24" Padding="2" TextAlignment="Center" Text="_" Canvas.Left="280" Canvas.Top="46"/> <Button Height="24" Width="90" Content="Schließen" Canvas.Left="300" Canvas.Top="46"/> </Canvas> </Window>
Have you found anything else in this direction?
Regards, Frank Schneller
This works for me.
var tmpIcon = Icon; // Create the PowerPlatform Interop Helper and Attach the Window _wpfHelper = new WPFInteropHelper(this) { ForwardEscapeKey = false, ForwardF1Key = false, ForwardFunctionKeys = false, }; Show(); _wpfHelper.Attach (TopoCloudClient.Addin, WindowStartupLocation != WindowStartupLocation.CenterOwner, Title); Icon = tmpIcon;
Thanks, that's it