UserControl作为UserControl ListView中的项[WinRT& XAML] [英] UserControl as Item in UserControl ListView [WinRT & XAML]

查看:84
本文介绍了UserControl作为UserControl ListView中的项[WinRT& XAML]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello社区!



尝试使用自定义ListView创建内容时遇到了一个小问题。



ListView是一个带有2个TextBox的UserControl,当然还有一个ListView。

现在,我有另一个UserControl与ListView完全相同,但没有List(2) TextBoxes)。



我想要达到的目的是:



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>





就像你看到的,我有一个名为ListViewControl的自定义ListView 和3个控件称为ValueBoxControl。我希望能够为程序编写完全类似的XAML,以便了解我想将3个ValueBoxControls作为项目放入ListViewControl的ListView(称为List)。



基本上,我希望它就像普通的ListView一样:





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>





但是由于ListViewControl是UserControl而不是ListView,它显然不起作用。 List是ListViewControl的子代。我怎样才能让它发挥作用?



我听说过有关ContentPropertyAttributes的内容,但我似乎无法让它工作。



我想在代码隐藏中做所有事情,所以我只能像普通的ListView一样输入ListViewItems。





感谢任何帮助。



问候

Narakuvera



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

推荐答案

这篇关于UserControl作为UserControl ListView中的项[WinRT&amp; XAML]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆