Here is my XAML:
<Window x:Class="Application.SeeProductVersions"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Application.ApplicationData"
Title="Product Versions" Height="300" Width="640" Loaded="Window_Loaded">
<Window.Resources>
<XmlNamespaceMappingCollection x:Key="VersionDataNamespaceMapping">
<XmlNamespaceMapping Uri="http://whereever.com/VersionData" Prefix="vdata" />
</XmlNamespaceMappingCollection>
<XmlDataProvider x:Key="ProductDataXmlFile" XmlNamespaceManager="{StaticResource VersionDataNamespaceMapping}"></XmlDataProvider>
</Window.Resources>
<ListView x:Name="m_lvProductVersions" ItemsSource="{Binding Source={StaticResource ProductDataXmlFile}, XPath=//vdata:PRODUCTDATA/vdata:PRODUCT}" Loaded="m_lvProductVersions_Loaded">
<ListView.View>
<GridView>
<GridViewColumn x:Name="colProduct" Width="64" Header="Product" DisplayMemberBinding="{Binding XPath=vdata:NAME}"/>
<GridViewColumn x:Name="colVersion" Width="64" Header="Version" DisplayMemberBinding="{Binding XPath=vdata:VERSION}"/>
<GridViewColumn x:Name="colLink" Width="256" Header="Download Link" DisplayMemberBinding="{Binding XPath=vdata:LINK}"/>
</GridView>
</ListView.View>
</ListView>
</Window>
Here is some sample XML:
<?xml version="1.0" encoding="utf-8"?>
<vdata:PRODUCTDATA xmlns:vdata="http://whereever.com/VersionData">
<vdata:PRODUCT>
<vdata:ID>04</vdata:ID>
<vdata:NAME>ProductWithALongName</vdata:NAME>
<vdata:VERSION>8.7.12.0</vdata:VERSION>
<vdata:LINK>http://www.whereever.com/support/LongNames/ProductWithALongName-download.asp</vdata:LINK>
</vdata:PRODUCT>
<vdata:PRODUCT>
<vdata:ID>07</vdata:ID>
<vdata:NAME>ModerateName</vdata:NAME>
<vdata:VERSION>9.12.5.0</vdata:VERSION>
<vdata:LINK>http://www.whereever.com/support/ModerateNames/ModerateName-download.asp</vdata:LINK>
</vdata:PRODUCT>
<vdata:PRODUCT>
<vdata:ID>16</vdata:ID>
<vdata:NAME>ShortName</vdata:NAME>
<vdata:VERSION>9.9.19.0</vdata:VERSION>
<vdata:LINK>http://www.whereever.com/support/ShortNames/ShortName-download.asp</vdata:LINK>
</vdata:PRODUCT>
</vdata:PRODUCTDATA>
FWIW, I get a path in the constructor for SeeProductVersions, grab the XmlDataProvider object from the Resources and shove a new Uri based on the path into Source.
I want to resize the columns after all the items have been loaded, and I was trying to do it in the Loaded handler for the ListView, but the items collection was empty then.
Is there an appropriate event to handle to perform this operation, or is there a neat way to do it in XAML? I did see one post that mentioned using a CellTemplate and catching the Loaded event from the cells....
I am sure I am violating MVVM all over the place, but since I am pretty new to WPF and XAML, I am not going to let that bother me too much!
Any help would be appreciated.