Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

newbie question: WPF Data Binding -  when to use "dynamic resource"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
indtaz - 29 Feb 2008 05:02 GMT
I am new to WPF and DataBinding.
I am trying to create a listbox that will display a list of images in
a stackpanel.
The images themselves are retried from a table defined in SQL Server.
( Database used is the AdventureWorks database)

I am currently able to retrieve the images from the database using an
SQL query.
However, I am not sure, how to implement the binding to display the
images in the listbox.
I am unclear about when/how to use "Static Resource"  and "Dynamic
Resource" for Data Binding.

Any pointers would be much appreciated.
Marc Vangrieken - 29 Feb 2008 11:00 GMT
Hi,

I'm fairly new to WPF myself, so maybe other can correct me where i'm
wrong... Afaik resources are things that are declared in a resources
section (eg. Window.Resources) and although you could use them in this
scenario it's unneeded. One thing you could do is set the DataContext
of the ListBox to the structure that contains you images (eg.
ImageCollection) retrieved from the database and then make an
itemtemplate like this:

<ListBox Name="listView1" ItemsSource="{Binding ImageCollection}"
   Background="Black"
   Margin="0,116,0,0">
   <ListBox.ItemsPanel>
       <ItemsPanelTemplate >
       <StackPanel />
       </ItemsPanelTemplate>
   </ListBox.ItemsPanel>
   <ListBox.ItemTemplate>
       <DataTemplate>
       <Image Source="{Binding Path=ImageCollection}" Width="70"
Stretch="Fill" Margin="5"/>
       </DataTemplate>
   </ListBox.ItemTemplate>
</ListBox>

Now, you can take this one step further and make for instance your
ItemTemplate a static resource. You can than bind the listboxs
ItemTemplate property using the StaticResource syntax..

I hope this helped..

Marc Vangrieken

> I am new to WPF and DataBinding.
> I am trying to create a listbox that will display a list of images in
[quoted text clipped - 10 lines]
>
> Any pointers would be much appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.