I’m trying to load a combobox from an XML file. There isn’t however a direct 1:1 relation between the structure of the file and the list item. I therefore have the following code snippets. XAML
<Window.Resources>
<ObjectDataProvider MethodName="GetConnectionAccountNames"
ObjectType="{x:Type gui:ConnectionAccountHelper}"
x:Key="connectionAccount">
<!--
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Format" />
</ObjectDataProvider.MethodParameters>
-->
</ObjectDataProvider>
</Window.Resources>
The combobox (which actually sits in an Infragistics Ribbon Control)
<igRibbon:ComboEditorTool
Id="ktsConnections"
x:Name="connectionsCombo"
DropDownResizeMode="VerticalOnly"
IsEditable="False"
EditAreaWidth="150.0"
ItemsSource="{Binding Source={StaticResource connectionAccount}}">
</igRibbon:ComboEditorTool>
The work is of course done in the method in the helper class
public static IEnumerable<string> GetConnectionAccountNames()
{
Dictionary<string, ConnectionAccount> accounts = HelperItems.GetSavedConnectionAccounts();
foreach (ConnectionAccount a in accounts.Values)
{
yield return a.Uri + ":" + a.PortDebug;
}
}
As far it goes it does actually build and work and give me the result I want. Only one thing I can’t explain. The designer will no longer display the window because it detects the following error on the ItemsSource="{Binding line. Could not find a part of the path 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Resources\ConnectionAccounts.xml'. The last part of the path is actually the path relative to the EXE’s location, where for the XML file. I’m at a loss as to how to get rid of that error. Does anyone have an idea? It makes no sense to me. Thanks in advance.
Happy programming!!