From: John on
I'm developing a fairly simple WPF solution. It's basically just a treeview
on the left side, and a listview on the other. Very similar to Windows
explorer in looking at the file system, but not with the file system. 8-)

Anyway, here's my problem:
My WPF listview has 5 columns. Each column has a name, and each column was
databound using a simple custom expression. e.g.:
<ListView.View>
<GridView>
<GridViewColumn Header="Column1" DisplayMemberBinding="{Binding A}"/>
<GridViewColumn Header="Column2" DisplayMemberBinding="{Binding B}"/>
<GridViewColumn Header="Column3" DisplayMemberBinding="{Binding C}"/>
<GridViewColumn Header="Column4" DisplayMemberBinding="{Binding D}"/>
<GridViewColumn Header="Column5" DisplayMemberBinding="{Binding E}"/>
</GridView>
</Listview.View>

When I select an item in my treeview, an event is fired (TreeItem_Selected).
This is basically what's in that function:
{
// Using Linq to SQL ...
var myData =
from someData in myDataContext.TableA
select new
{
someData.A,
someData.B,
someData.C,
someData.D,
someData.E
}

myListViewControl.ItemsSource = myData;
e.Handled = true;
}

This all worked fine. All of my columns would get populated with the
correct strings, and life was good. Now, I wanted to replace the content in
Column1 with a custom control that I have created instead of just using the
text string. This is the part I can't seem to get to work. This is what I
initially tried in my event handler:

{
var myConverter = new ImageSourceConverter();

// Using Linq to SQL ...
var myData =
from someData in myDataContext.TableA
select new
{
A = new myCustomControl()
{
myTextBlockItemInThisControl = new TextBlock()
{
Text = someData.A
},
myImageInThisControl = new Image()
{
Source = (ImageSource)
myConverter.ConvertFromString("myImage.png")
}
},
B = someData.B,
C = someData.C,
D = someData.D,
E = someData.E
}

myListViewControl.ItemsSource = myData;
e.Handled = true;
}

Instead of displaying my custom control that I've developed inside of
column1, instead I just get some crazy text string that belongs to some
object. The XAML for my custom control is:

<UserControl
xmlns ... (Blend generated stuff)
x:Class="MyNamespace.myCustomControl"
x:Name="theControl"
d:DesignWidth="640" d:DesignHeight="480"

<Grid x:Name="LayoutRoot">
<StackPanel x:Name="myStackPanel" Orientation="Horizontal">
<Image x:Name="myImageInThisControl" Source="anImage.png" WIdth="20"/>
<TextBlock x:Name="myTextBlockItemInThisControl" TextWrapping="Wrap"
VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</UserControl>

I guess the short version is, using the crazy Linq-SQL statement above, how
can I bind this control to Column1 in my listview?

Thanks.