WPF: How do I know if Binding RelativeSource found an ancestor - wpf

I'm using the binding RelativeSource with the FindAncestor Mode but the binding is not working. How do I debug and see if It is able to find the ancestor?

use Snoop
EDIT: you can of course use the usual debugging mechanisms, but I like Snoop the best. You can navigate to your control and if your binding failed it tells you so

Or you can set PresentationTraceSources.TraceLevel on the binding.
If you are using VS2010 remember to set the Data binding value in Options->Debugging->Output Window

I use WPF Inspector, it's a nice free tools for debugging WPF application in XAML level.

Related

Binding a WPF element host to a WinForm property

I have a WPF element host sitting in a WinForm.
I would like to bind a property of the element to a property of the WinForm.
In my searches I found the opposite solution, binding between WinForms to WPF properties (when the WinForm is sitting on a WPF host).
Here is an example:
How to bind a windows control in WPF????
I also saw this answer (not exactly an answer, I'd say a conclusion): Binding to a WPF hosted control's DependencyProperty in WinForms
It did not help me. I also want to keep the the principle of MVVM in the WPF element host.
|It there a way to do this?
Finally I solved it this way:
I created a property in ViewModel and init him through the WinForm when I use the wpf host control in the first time.
I binding the property to element in xaml
and that's all.

Trick for seeing databound list controls in the VS XAML Editor

Is there any way to see what a control will look like in the XAML designer when it's ItemSource property is databound? I want to see what it looks like in the designer somehow without actually running the application.
Here's a good article by Karl Shifflett that explains how to display design-time data :
http://karlshifflett.wordpress.com/2008/10/11/viewing-design-time-data-in-visual-studio-2008-cider-designer-in-wpf-and-silverlight-projects/
WPF 4 will come with native support of design-time data

WPF and ToolboxItem(false)

I'm setting ToolboxItem(false) attribute on couple of classes in my control library to prevent the from being added to Toolbox. This attribute works perfectly well with ASP.NET designer but with WPF designer it seems to have no effect.
Is there some other way to achieve this with WPF or is just unsupported?
Found the answer myself. You should use ToolboxBrowsable(false) attribute from Microsoft.Windows.Design namespace rather than ToolboxItem(false) from System.ComponentModel.

WPF Docking Manager with Databinding support

Does anyone know about a Docking Control like Visual Studio for WPF, where Databinding for the Panes is supported?
I tried the DockManager from Infragistics and from Actipro, but they lack this support.
For example, the Panes for the content need to be bound through Databinding, so removing the Entity on the other side of the binding would also remove it from the DocumentHost.
Any Idea? Or a lightweight workaround for any control?
Full databinding support from every control is crucial for my project.
Thanks in advance.
You might consider AvalonDock on Codeplex. If it doesn't have the functionality you are looking for you can add it yourself since you get full source code!
I know this won't help the original poster but in case someone else comes across this with a similar question, there is a blog post with a sample using an attached property to implement binding support in the Infragistics XamDockManager.

How to notify the user about binding errors in silverlight?

To my understanding, binding errors are displayed only during debug mode in Visual Studio's Output window. However, I want to know about broken bindings when the user runs my app, and I want to notify him that something is not working quite right.
Is there a way to handle binding exceptions from code, when the datacontext is set, and some bindings are broken?
It's possible to catch all Silverlight binding exceptions in all property setters. See here.

Resources