Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Custom ListBox with Custom Button

$
0
0

Dears, 

I created a custom button and a custom listbox, and would in part of the visual studio design had an easier way to add this button to my listbox, I can now by clicking Items (collection) -> The Collector Editor: items I select in the combo "Other types" -> My button and I click on Add So it has worked, but wanted to create a property in property window with the new button that when clicked will add my button to my listbox. 

The is code for my listbox.

Public Class myListBox

    Inherits ListBox

    Public Property AddButton() As myButton
        Get
            Return New myButton
        End Get
        Set(value As myButton)
            MyBase.Items.Add(New myButton)
        End Set
    End Property

End Class

This way it appears in there as AddButton Properties window and the New button on the front, when you click it it adds to the xaml the following code:

local:myListBox.AddButton>
                <local:myButton/>
</local:myListBox.AddButton>

Only having two problems, it just adds a button in xaml even clicking several times, and the run button disappears. 

How do I get this to work? 

I thank the attention received and sorry for my bad english.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>