Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Binding a ComboBox to in internal property

 
 
Old 10-03-2006   #1 (permalink)
Keith Patrick


 
 

Binding a ComboBox to in internal property

I haven't done much WPF since last September/October & am trying to bind a
combobox on my window to a property in the window itself. Basically, I want
to have the equivalent of a NavigationWindow (or IE7's) history next to the
back/forward buttons that are based on a journal (due to sizing issues, I
can't use NavigationWindow). I've been doing a lot of ASP.Net lately, so
I'm aiming for the equivalent of:

<aspropDownList runat="server" DataSource="<%# GetItems() %>"/>
protected IEnumerable GetItems() {
return new String[] {"one", "two", "three"};
}

However, I've tried using ElementName (referencing the root window) and Path
(referencing the property) with no luck, and I haven't seen any samples that
do this. It's a pretty rudimentary task, but I'm having some issues moving
out of the ASP.Net mindset (which leads me to yet again chime in that I hope
those two markup models begin to unify)



My System SpecsSystem Spec
Old 10-04-2006   #2 (permalink)
Douglas Stockwell


 
 

Re: Binding a ComboBox to in internal property

What you have described should work. In principle it's the same as this
example.

<Grid Name="Grid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<TextBlock Text="{Binding ElementName=Grid, Path=ActualWidth}" />
</Grid>

Assuming you defined a property rather a method, and marked it as public not
protected.

- Doug

"Keith Patrick" <richard_keith_patrick@nospam.hotmail.com> wrote in message
news:eY1yZ1z5GHA.3436@TK2MSFTNGP03.phx.gbl...
>I haven't done much WPF since last September/October & am trying to bind a
>combobox on my window to a property in the window itself. Basically, I
>want to have the equivalent of a NavigationWindow (or IE7's) history next
>to the back/forward buttons that are based on a journal (due to sizing
>issues, I can't use NavigationWindow). I've been doing a lot of ASP.Net
>lately, so I'm aiming for the equivalent of:
>
> <aspropDownList runat="server" DataSource="<%# GetItems() %>"/>
> protected IEnumerable GetItems() {
> return new String[] {"one", "two", "three"};
> }
>
> However, I've tried using ElementName (referencing the root window) and
> Path (referencing the property) with no luck, and I haven't seen any
> samples that do this. It's a pretty rudimentary task, but I'm having some
> issues moving out of the ASP.Net mindset (which leads me to yet again
> chime in that I hope those two markup models begin to unify)
>


My System SpecsSystem Spec
Old 10-04-2006   #3 (permalink)
Keith Patrick


 
 

Re: Binding a ComboBox to in internal property

Ahhh, my problem was that I marked the property as protected (ASP.Net allows
for protected binding, and WPF won't throw an exception - which is
surprising to me) instead of public

Thanks!


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
binding to combobox itemssource? .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46