Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do you need to instantiate Tags?</p> <p>I'm guessing it's a null reference exception, you set your items source as Tags in your constructor, but you have not instantiated Tags.</p> <pre><code>public TagCloudControl() { Tags = new ObservableCollection&lt;Tags&gt;(); ItemsSource = Tags; ... } </code></pre> <p>Edit:</p> <p>After playing around with code... I'm thinking that Tags might not need to be a DependencyProperty. It appears you want to Bind the ItemsSource to Tags... but you could just make Tags a simple property, and in it, set the ItemsSource to the value passed in:</p> <pre><code>public TagCloudControl() { //this is now empty. } public IEnumerable&lt;Tag&gt; Tags { get { return (this.ItemsSource as IEnumerable&lt;Tag&gt;); } set { this.ItemsSource = value; } } </code></pre> <p>Also I think your Style might want to be more like this:</p> <pre><code>&lt;Style TargetType="{x:Type local:TagCloudControl}"&gt; &lt;Setter Property="ItemTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate DataType="{x:Type local:Tag}"&gt; &lt;TextBlock Text="{Binding Name}" FontSize="{Binding ItemCount, Converter={StaticResource CountToBrushConverter}}" Foreground="{Binding ItemCount, Converter={StaticResource CountToFontSizeConverter}}"&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type local:TagCloudControl}"&gt; &lt;Grid&gt; &lt;WrapPanel Orientation="Horizontal" Margin="2" IsItemsHost="True"&gt; &lt;/WrapPanel&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>And finally, I think you might be missing ItemCount in your 'Tag' Class.</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.
 

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