Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can you bind an attached property to DisplayMemberPath of a ComboBox?
    primarykey
    data
    text
    <p>I can't seem to find the correct syntax to allow an attached property to be used as the DisplayMemberPath of a ComboBox.</p> <p>The property is SelectorSwitchedControl.NameForSelector<br> It's in the namespace 'LocalTest' which is mapped to the XAML prefix 'local'. </p> <p>Here's the code...</p> <pre><code>&lt;UserControl x:Class="Playground.SelectorSwitchedControlTest.SelectorSwitchedControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:glc="clr-namespace:Playground.CommonControls" xmlns:local="clr-namespace:Playground.SelectorSwitchedControlTest" Background="Transparent"&gt; &lt;Border x:Name="MainBorder" BorderBrush="Gray" BorderThickness="1"&gt; &lt;DockPanel&gt; &lt;glc:FixedToolBar DockPanel.Dock="Top"&gt; &lt;ComboBox x:Name="MainSelector" ItemsSource="{Binding Children, ElementName=MainPanel}" DisplayMemberPath="(local:SelectorSwitchedControl.NameForSelector)" /&gt; &lt;/glc:FixedToolBar&gt; &lt;local:SelectorSwitchedControlPanel x:Name="MainPanel" /&gt; &lt;/DockPanel&gt; &lt;/Border&gt; &lt;/UserControl&gt; </code></pre> <p>...which for some reason gives me the exception 'Prefix 'local' does not map to a namespace.' which I'm not sure why it's saying that as if I remove the 'DisplayMemberPath' line, the '' tag renders just like it's supposed to proving the namespace is mapped.</p> <p>I've also tried all of the following...</p> <ul> <li>DisplayMemberPath="local:SelectorSwitchedControl.NameForSelector"</li> <li>DisplayMemberPath="(local:SelectorSwitchedControl.NameForSelector)"</li> <li>DisplayMemberPath="SelectorSwitchedControl.NameForSelector"</li> <li>DisplayMemberPath="(SelectorSwitchedControl.NameForSelector)"</li> <li>DisplayMemberPath="LocalTest.SelectorSwitchedControl.NameForSelector"</li> <li>DisplayMemberPath="(LocalTest.SelectorSwitchedControl.NameForSelector)"</li> </ul> <p>I know it's just one of those days where my mind isn't working and I'm missing something simple, but it's driving me crazy! So what's the proper syntax?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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