Click here to Skip to main content
15,916,527 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 3:50
fjparisIII25-Jun-09 3:50 
GeneralRe: Data binding from a List to a Grid Pin
ABitSmart25-Jun-09 5:48
ABitSmart25-Jun-09 5:48 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 8:22
fjparisIII25-Jun-09 8:22 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 5:41
fjparisIII25-Jun-09 5:41 
GeneralRe: Data binding from a List to a Grid Pin
ABitSmart25-Jun-09 5:45
ABitSmart25-Jun-09 5:45 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 8:26
fjparisIII25-Jun-09 8:26 
AnswerRe: Data binding from a List to a Grid Pin
mittalamit24-Jun-09 20:18
mittalamit24-Jun-09 20:18 
GeneralRe: Data binding from a List to a Grid (unfortunately, it did not work) [modified] Pin
fjparisIII25-Jun-09 4:56
fjparisIII25-Jun-09 4:56 
mittalamit wrote:
You need not to define the RelativeSource to the name of your window
Might be this code may work:

Source="{Binding Path=DataContext.PhotoMetadataList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"

If doesn't work Please response.


First, as I mentioned, don't think of my container as a WPF Grid. Think of it as a WPF ListView, because that's the correct model for the 3rd party control I'm actually using. But that has nothing to do with your suggestion.

I've already tried something similar to what you suggest but I left DataContext off of the path and omitted FindAncestor, but it didn't work. That's what the 3rd party tech support person suggested. So then I tried your suggestion and that didn't work, either.

I also tried the following, and it didn't work:

Source="{Binding Mode=OneWay, <br />
         RelativeSource={RelativeSource AncestorType=local:PhotoInformationWindow}, <br />
         Path=DataContext.PhotoMetadataList}"


I'm still out in the cold and have been tempted to drop this 3rd party control and go to the native WPF ListView, but I have a feeling I'd have exactly the same problem. There must be something fundamental that I'm missing, but I'm not a XAML guru, which is why I came to this forum. Tech support of the 3rd party control isn't much help, either.

Maybe the following is a hint to my problem. If PhotoMetadataList is in Application.Current, it almost works with the following XAML:

Source="{Binding Source={x:Static Application.Current}, Path=PhotoMetadataList}"

But there are two things wrong with this:

1. Putting my data source in Application.Current is like using the discredited notion of global data. It would also mean that I'd have to have a way of associating a different path for each window containing my ListView, and that might be challenging to express it in XAML (I sure don't know how to do that off the top of my head).

2. Using the above binding, I still have a couple problems. First, the ListView (or the 3rd party equivalent) doesn't display any data the first time I create the window. But it does on subsequent creations of the window. Second, the ListView never changes its values after the first display, no matter how I change the source. It's acting like a static rather than a dynamic binding.

Added later from another post I made in this thread: "'I didn't know what DataContext was, so looked it up. MSDN: 'Represents the main entry point for the LINQ to SQL framework.' I'm using neither LINQ nor SQL and don't know beans about either." So I guess your suggestion about DataContext is not relevant to my approach. Internally, PhotoMetadataList is of type, List<PhotoMetadata> and PhotoMetadata is a class derived from INotifyPropertyChanged. The data for PhotoMetadata is taken from the image metadata written into photographic image files by digital cameras, and so my data source is not a database, but the metadata in digital image files.

modified on Thursday, June 25, 2009 11:45 AM

AnswerRe: Data binding from a List to a Grid Pin
Mark Salsbery25-Jun-09 6:58
Mark Salsbery25-Jun-09 6:58 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 7:31
fjparisIII25-Jun-09 7:31 
GeneralRe: Data binding from a List to a Grid Pin
Mark Salsbery25-Jun-09 7:48
Mark Salsbery25-Jun-09 7:48 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 8:30
fjparisIII25-Jun-09 8:30 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 7:39
fjparisIII25-Jun-09 7:39 
GeneralRe: Data binding from a List to a Grid Pin
Pete O'Hanlon25-Jun-09 9:07
mvePete O'Hanlon25-Jun-09 9:07 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 9:29
fjparisIII25-Jun-09 9:29 
AnswerRe: Data binding from a List to a Grid Pin
Mark Salsbery25-Jun-09 7:23
Mark Salsbery25-Jun-09 7:23 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 7:40
fjparisIII25-Jun-09 7:40 
GeneralRe: Data binding from a List to a Grid Pin
Mark Salsbery25-Jun-09 7:46
Mark Salsbery25-Jun-09 7:46 
GeneralRe: Data binding from a List to a Grid Pin
fjparisIII25-Jun-09 8:33
fjparisIII25-Jun-09 8:33 
AnswerRe: Data binding from a List to a Grid (Everything works now) [modified] Pin
fjparisIII25-Jun-09 12:19
fjparisIII25-Jun-09 12:19 
QuestionWPF Slider project Pin
fgimenez24-Jun-09 8:14
fgimenez24-Jun-09 8:14 
AnswerRe: WPF Slider project Pin
Christian Graus24-Jun-09 15:26
protectorChristian Graus24-Jun-09 15:26 
GeneralRe: WPF Slider project Pin
fgimenez29-Jun-09 2:49
fgimenez29-Jun-09 2:49 
QuestionSilverlight2Chat Pin
deep7624-Jun-09 4:59
deep7624-Jun-09 4:59 
AnswerRe: Silverlight2Chat Pin
Mark Salsbery24-Jun-09 7:35
Mark Salsbery24-Jun-09 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.