|
|
|
start date: Thu, 26 Jul 2007 13:50:03 -0700,
posted on: microsoft.public.dotnet.framework.sdk
back
| Thread Index |
|
1
Jim Hudson am
|
|
2
(Walter Wang [MSFT])
|
|
3
(Walter Wang [MSFT])
|
|
4
Jim Hudson am
|
|
5
(Walter Wang [MSFT])
|
|
6
Jim Hudson am
|
|
7
(Walter Wang [MSFT])
|
Binding to XPath with prefix in GridViewColumn?
I have a ListView with an ItemSource that is bound to some XML, via {Binding
Xpath=...}. The ListView.View is defined with a GridView. In the individual
GridViewColumn elements, I'd like to specify DisplayMemberBinding, and bind
to the various XML elements. If my XML is specified with the default
namespace, then everyting works like a charm:
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding XPath=name}" />
However, my production XML relies on several namespaces, and so my
production XML element names have a prefix. When I change my XAML code to
use an XmlNamespaceManager, everything ELSE works with the prefixed XPaths,
except for the GridViewColumns. Thus the following:
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding
XPath=cap:name}" />
doesn't work. Found a solution (somewhere on the Internet) that proposed
switching from DisplayMemberBinding to using a CellTemplate, but that didn't
work either.
Any other ideas?
--
Jim Hudson
Date:Thu, 26 Jul 2007 13:50:03 -0700
Author:
|
RE: Binding to XPath with prefix in GridViewColumn?
Hi Jim,
This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Fri, 27 Jul 2007 13:20:51 GMT
Author:
|
RE: Binding to XPath with prefix in GridViewColumn?
Hi Jim,
I've done some research and following code works on my side:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<XmlNamespaceMappingCollection x:Key="mapping">
<XmlNamespaceMapping Uri="http://foo" Prefix="foo" />
</XmlNamespaceMappingCollection>
<XmlDataProvider x:Key="Books" Source="Books.xml"
XmlNamespaceManager="{StaticResource mapping}" />
</Window.Resources>
<StackPanel>
<TextBlock>ListView</TextBlock>
<ListView>
<ListView.ItemsSource>
<Binding Source="{StaticResource Books}"
XPath="foo:Books/foo:Book" />
</ListView.ItemsSource>
<ListView.View>
<GridView>
<GridViewColumn Header="Name"
DisplayMemberBinding="{Binding XPath=foo:Name}" />
</GridView>
</ListView.View>
</ListView>
<TextBlock>ListBox</TextBlock>
<ListBox>
<ListBox.ItemsSource>
<Binding Source="{StaticResource Books}"
XPath="foo:Books/foo:Book"/>
</ListBox.ItemsSource>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding XPath=foo:Name}">
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Window>
Books.xml
<?xml version="1.0" encoding="utf-8" ?>
<foo:Books xmlns:foo="http://foo">
<foo:Book>
<foo:Name>First</foo:Name>
</foo:Book>
</foo:Books>
Please test this and let me know the result. Thanks.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 30 Jul 2007 07:22:16 GMT
Author:
|
RE: Binding to XPath with prefix in GridViewColumn?
Your ListView didn't work on my machine. I modified your code, a little, to
make sure that the ListView was doing anything. The modified code is:
<StackPanel>
<TextBlock>ListView</TextBlock>
<ListView ItemsSource="{Binding Source={StaticResource Books},
XPath=foo:Books/foo:Book}" >
<ListView.View>
<GridView>
<GridViewColumn Header="Name1" DisplayMemberBinding="{Binding
XPath=foo:Name}" />
<GridViewColumn Header="Row?" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="A Row" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<TextBlock>ListBox</TextBlock>
<ListBox ItemsSource="{Binding Source={StaticResource Books},
XPath=foo:Books/foo:Book}" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding XPath=foo:Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
I also added 3 more <foo:Book> nodes into Books.xml. When I run the
application, the window looks like this:
----------------------------------------
| ListView
| Name1 Row?
| A Row
| A Row
| A Row
| A Row
| ListBox
| First
| Second
| Third
| Fourth
----------------------------------
Given that your code works properly on your machine, I have to conclude that
the problem is in the particular release of the .Net 3.0 WPF assemblies
installed on my computer.
Here's where I get a little confused. In my VS2005 project file, the
references for PresentationCore and PresentationFramework both go to dlls in
"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0".
Those DLLs are listed as "Runtime Version v2.0.50727, Version 3.0.0.0".
However, my GAC contains different versions of the same 2 assemblies: the
GAC assemblies are marked as "Product Version 3.0.6912.0 Version 3.0.0.0"
(BTW, I'm doing this testing on a Vista Business 64-bit system).
Have I installed out-of-date copies of the WPF/WCF Framework SDKs?
--
Jim Hudson
Date:Fri, 3 Aug 2007 13:34:03 -0700
Author:
|
RE: Binding to XPath with prefix in GridViewColumn?
Hi Jim,
After further testing, this looks like an issue of .NET Framework 3.0 but
fixed in .NET Framework 3.5 Beta 2. Please install .NET Framework 3.5 Beta
2 from here:
#Download details: .NET Framework 3.5 Beta 2
http://www.microsoft.com/downloads/details.aspx?familyid=d2f74873-c796-4e60-
91c8-f0ef809b09ee&displaylang=en
We're sorry for the inconvenience caused by this. I'll file a bug for it.
Please note the RTM version of .NET Framework 3.5 is scheduled to be
released at end of 2007; beta 2 of it is also included in VS2008 (aka
Orcas) beta 2, which can be downloaded here:
http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Mon, 06 Aug 2007 03:19:29 GMT
Author:
|
RE: Binding to XPath with prefix in GridViewColumn?
Thanks for the info, Walter. I'll pass the word about those 2 beta versions
around here at my company.
--
Jim Hudson
Date:Mon, 6 Aug 2007 05:22:00 -0700
Author:
|
RE: Binding to XPath with prefix in GridViewColumn?
Hi Jim,
Thanks for your quick reply. Please feel free to let me know if you have
any concerns or questions about this issue.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Tue, 07 Aug 2007 02:26:41 GMT
Author:
|
|
|