Mahapps WPF - Strange behavior with combobox binding

Viewed 696

I'm having a strange behavior when I add icons to the ComboBox.ItemTemplate. After initially loading the items, all of them are showing their corresponding icon, but when I select one item, the icon will show in the Combo Part but will disappear in the Expander Part.

You can see the problem here (imgur) enter image description here

I'm not experienced in WPF/C#, is there something wrong with the way I'm binding the items or the ComboBox.ItemTemplate?

Thanks a lot for the help.-

XAML Code

    <ComboBox x:Name="comboBox" HorizontalAlignment="Left" Height="32" Margin="60,47,0,0" VerticalAlignment="Top" Width="282" ItemsSource="{Binding OtherTasks}" >
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <DockPanel Margin="0" Height="30">
                    <ContentControl Content="{Binding Path=Icono}" Margin="0,4,0,0" Background="Yellow" Width="16" Height="16" Visibility="Visible"/>
                    <AccessText HorizontalAlignment="Stretch" Margin="3,4,0,0" Text="{Binding Path=Text}" TextAlignment="Left" Width="Auto" />
                </DockPanel>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

CS Code

namespace test___icon {
    public partial class MainWindow : MetroWindow {

        public class CLASS_OTHERTASKS {
            public string Text { get; set; }
            public object Icono { get; set; }
        }

        public List<CLASS_OTHERTASKS> OtherTasks { get; set; }

        public MainWindow() {
            OtherTasks = new List<CLASS_OTHERTASKS>();
            OtherTasks.Add(new CLASS_OTHERTASKS() { Text = "Test Air", Icono = new PackIconEntypo() { Kind = PackIconEntypoKind.Air } });
            OtherTasks.Add(new CLASS_OTHERTASKS() { Text = "Test Account", Icono = new PackIconMaterial() { Kind = PackIconMaterialKind.Account } });
            OtherTasks.Add(new CLASS_OTHERTASKS() { Text = "Test AxisThree", Icono = new PackIconModern() { Kind = PackIconModernKind.AxisThree } });

            InitializeComponent();
            this.DataContext = this;
        }
    }
}
1 Answers
Related