index > Windows Presentation Foundation ("Avalon") > Problems with multiple ObjectDataProviders - Attn: Binding gurus

Problems with multiple ObjectDataProviders - Attn: Binding gurus

Ok, here's the resource declaration of the ObjectDataProviders (ODPs) in question (may look familair to some of you)

<ObjectDataProvider x:Key="PreOpen" ObjectType="{x:Type src:SingleValueBinder}" />
<ObjectDataProvider ObjectInstance="{StaticResource PreOpen}" MethodName="set_SettingName" x:Key="PreOpenInstance">
<ObjectDataProvider.MethodParameters>
<sys:String>PreOpen</sys:String>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

Here is the XAML that binds to the control

<CheckBox Margin="10,10,10,10" Content="Pre-Open">
<CheckBox.IsChecked>
<Binding Path="Value" Source="{StaticResource PreOpenInstance}" >
</CheckBox.IsChecked>
</CheckBox>

When I execute my app., the Method executes on PreOpenInstance as expected. However, I don't see any source data because the control is bound to the second ODP, whereas the data source resides in the object associated with the first ODP.

I get the BindingExpression from the control (element) and call UpdateTarget, but there is nothing reflected in the UI, presumably because it pointing at the second ODP.

How do I Iink the BindingExpression to the correct source object (ODP 1)

Thanks




Recovering MSFT-SDE
NickNotYet
Actually, if you want to just set the property value in xaml, you can do this:
<src:SingleValueBinder SettingName="Bar" x:Key="valueBinder"/>
<ObjectDataProvider ObjectInstance="{StaticResource valueBinder}" x:Key="dataObject"/>

Sheva
footballism

Ok, that resolves my previous post on the subject. See here.

http://forums.microsoft.com/MSDN/showpost.aspx?postid=728101&siteid=1

Can the ObjectDataProvider problem that I described in this post be resolved? Just curious at this point.




Recovering MSFT-SDE
NickNotYet
The solution should also solve your binding problem because binding to the single ODP will bind to the object like it's supposed to.


What's in your toolbelt? http://www.codeplex.com/Wiki/View.aspx?ProjectName=wpftoolbelt
ivolved_Mike_Brown

Yes, indeed, made my day to get this resolved.

My DataBinding implementation appears to be doable without code-behind or too many nasty hacks. And this stuff is starting to sink into my brain a little.

Thanks Sheva for the improved solution and Mike, for putting up with my newbie questions.




Recovering MSFT-SDE
NickNotYet
Yeah I don't think what you're doing would fit into my newbie category


What's in your toolbelt? http://www.codeplex.com/Wiki/View.aspx?ProjectName=wpftoolbelt
ivolved_Mike_Brown
reply 6

You can use google to search for other answers

 

More Articles

• Multiple background images
• Sliding elements
• export to image with black block
• x:Static works as element but not as attribute with statics from ...
• how to create Hyperlink inside textblock from codebehind
• Pan
• Resource Dictionary "Adding Stroke/StrokeThickness" IsM...
• TextRange
• LinearGradientBrush and gamma
• Repeating controls
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Bug Fixes
• Gotfocus WPF button timer
• Need HELP getting started with WPF... (d
• Converting a collection to comma seperat
• unable to focus to a control
• Editable TreeView
• Is there any SplitContainer Control?
• Items.SourceCollection is not flushed wh
• Howto: make the Enter key work like the
• Viewport3D and real time
• Dynamic Gridview columns Update
• Using ContextMenuOpening to populate Con
• AtlasControlToolkit controls in WPF!!
• WPF App Disassembler
• How to collapse databound TextBlock

Hot Articles

• Running application from installer
• Elements wrapping in Panel
• WPF Query
• RichTextBox, get Insert mode?
• Using Canvas.SetTop is only working in d
• Vista style blur?
• Post file in WinFX
• FormsAuthenticationCookie in WPF
• Remove the Navigation Bar from xaml Page
• What facilities does WPF have for restri
• What is "best practise" for da
• GridViewColumnHeader: Prevent column reo
• Vertical lines in the GridView
• Set Up project is not working properly
• checkbox capture

Recommend Articles

• ListBox item scroll animation
• Pack Uri throws exception
• Viewport3D and real time
• hidden controls showing sometimes.
• PreviewMouseMove event of Canvas not rec
• WPF Query
• How get click event from button embedded
• Refresh ImageBox
• datbing listview with a generic sortedli
• VS 2005 Extensions for .NET 3.0 RC1
• Inconsistence for DataTemplate.FindName
• create and open a new window
• RTC application in C#
• .NET 3.0 and Expression Interactive Desi
• Windows Vista Explorer-like application