Click here to Skip to main content
15,886,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Community!

I've encountered a small problem when trying to create something with a custom ListView.

The ListView is a UserControl with 2 TextBoxes and, of course, a ListView.
Now, I have another UserControl which is exactly the same like the ListView, but without the List (2 TextBoxes).

What I want to achieve is this:

<local:ListViewControl Text="35000.005550" TextBoxWidth="300" TitleContent="ControlView" HorizontalAlignment="Left" Width="400" Foreground="Black" 
IsAngular="True" IsEnabled="True" ClipColor="#FFAE3B3B" Height="41"> 
         
        <local:ValueBoxControl Text="Test1" TitleContent="Title1" Width="300"        HorizontalAlignment="Left" IsEnabled="True"/>
        <local:ValueBoxControl Text="Test1" TitleContent="Title1" Width="300" HorizontalAlignment="Left" IsEnabled="True"/>
        <local:ValueBoxControl Text="Test1" TitleContent="Title1" Width="300" HorizontalAlignment="Left" IsEnabled="True"/>

</local:ListViewControl>


Like you see, I have a custom ListView called "ListViewControl" and 3 Controls called "ValueBoxControl". I want to be able to write the XAML exactly like this for the program to understand that I want to put the 3 ValueBoxControls as Items into the ListViewControl's ListView (which is called "List").

Basicly, I want it to be just like a normal ListView:

<ListView x:Name="listView1" SelectionChanged="ListView_SelectionChanged">
  <x:String>Item 1</x:String>
  <x:String>Item 2</x:String>
</ListView>


But since the ListViewControl is a UserControl and not a ListView, it will obviously not work. The List is a child of the ListViewControl. How can I get this to work?

I've heard something about ContentPropertyAttributes, but I can't seem to get it to work.

I want to do everything in code-behind, so I can only type in the ListViewItems just like in a normal ListView.


Any help is appreciated.

Greetings
Narakuvera
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900