Cast exception with ItemsControl
Posted: 16 Jun 2020, 19:02
Hello,
I am stuck with a cast problem on two ItemsControl which have for ItemPanel a WrapPanel and a StackPanel.
Here is the code for the WrapPanel:
And I got this when I launch it on Unity:
Thank you in advance!
I am stuck with a cast problem on two ItemsControl which have for ItemPanel a WrapPanel and a StackPanel.
Here is the code for the WrapPanel:
Code: Select all
<ItemsControl x:Name="SessionsList" Style="{StaticResource SessionPanelStyle}">
<!--GENERATED SESSION TILES HERE-->
</ItemsControl>
Code: Select all
<Style x:Key="SessionPanelStyle" TargetType="ItemsControl">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel Style="{DynamicResource TilesPanel}"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border>
...
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
Code: Select all
private ItemsControl SessionsList;
private void InitializeComponent()
{
Noesis.GUI.LoadComponent(this, "Assets/WPF/File.xaml");
SessionsList = (ItemsControl)FindName("SessionsList");;
}
Code: Select all
public void FillSessionsList()
{
SessionsList.Items.Clear();
var tile = new SessionTile()
{
...
};
SessionsList.Items.Add(tile);
}
Do you have an idea? Do you need more informations?InvalidCastException: Specified cast is not valid.
Thank you in advance!