Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.data.relativesource.templatedparent.aspx" rel="nofollow"><code>RelativeSource.TemplatedParent</code></a> is for <code>ControlTemplates</code>, here you should just bind to the DataContext by not specifying any source:</p> <pre><code>{Binding Path=Name} </code></pre> <p>or simply</p> <pre><code>{Binding Name} </code></pre> <p><strong>Edit:</strong> The control being a custom control i would ditch this approach (i don't know if it even can work) like that unless maybe you manually write a lot of code VS would normally write for you.</p> <p>When you created the control and your project did not have a generic theme yet it should have created a <code>Themes</code> folder and a <code>Generic.xaml</code>, in that class you can set the properties in the style instead (note the <code>BasedOn</code> which gets the template and other properties from the default ItemsControl):</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:SandBox1.CustomControls"&gt; &lt;Style TargetType="{x:Type local:WorkspacePanel}" BasedOn="{StaticResource {x:Type ItemsControl}}"&gt; &lt;Setter Property="ItemsPanel"&gt; &lt;Setter.Value&gt; &lt;ItemsPanelTemplate&gt; &lt;StackPanel IsItemsHost="True" Orientation="Horizontal" HorizontalAlignment="Left" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="ItemTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate&gt; &lt;Button Content="{Binding Name}" /&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre>
    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