Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding error on WPF (biding to DataContext)
    primarykey
    data
    text
    <p>First of all let me say that I'm rather new to WPF, so excuse me for any silly mistakes, but I've been cracking my head at this for a while now.</p> <p>I have a simple sollution with three classes:</p> <pre><code>public class MyCustomItem public class MyCustomLayout : ThirdPartyLayout&lt;MyCustomItem&gt; public class MyViewController : INotifyPropertyChanged </code></pre> <p>MyCustomItem is a simple class with some properties ("Name" being one of them). ThirdPartyLayoutTool is a generic component inside an SDK that inherits from System.Windows.Controls.Panel. And MyViewController is the view controller I'm using as a data content.</p> <p>I then created this simple XAML as the projects main window:</p> <pre><code>&lt;Window x:Class="DependencyViewer.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sdk="clr-namespace:Sdk;assembly=Sdk" xmlns:local="clr-namespace:MyNamespace" Title="MainWindow" Height="350" Width="525"&gt; &lt;local:MyCustomLayout x:Name="myLayout"/&gt; &lt;/Window&gt; </code></pre> <p>Everything displays accordingly.Now my objective is to enhance the display of one of the sub components that is displayed by the ThirdPartyLayout panel, called TargetControl. So I add the following code:</p> <pre><code>&lt;Window.Resources&gt; &lt;Style TargetType="{x:Type sdk:TargetControl}"&gt; &lt;Style.Resources&gt; &lt;ToolTip x:Key="ToolTipContent"&gt; &lt;StackPanel&gt; &lt;TextBlock FontWeight="Bold" Text="Testing 1 2 3"/&gt; &lt;TextBlock Text="{Binding Name}"/&gt; &lt;/StackPanel&gt; &lt;/ToolTip&gt; &lt;/Style.Resources&gt; &lt;Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; </code></pre> <p>When I run the code, the "Testing 1 2 3" message appears correctly, however, I don't see the Name property. On the output window, I get the following message:</p> <p><code>BindingExpression path error: 'Name' property not found on 'object' ''MyViewController' (HashCode=31884011)'</code></p> <p>What I don't get is why the binding is happening on the MyViewController class, instead of TargetControl class. Any ideas?</p> <p>Best regards, Carlos Jourdan</p> <p>EDIT:</p> <p>After tinkering guide mainly by the recommendations given by newb, I eventually found out that the source of the error is in fact in the SDK. The current release is still faulty, but when compiling from source I get the expected behavior.</p> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload