Listview 主页中自定义类项目的使用情况?地铁应用程序
我想定义一个自定义类,它有一个图像和一个文本块 自定义类Listview 主页中自定义类项目的使用情况?地铁应用程序,listview,listbox,windows-8,microsoft-metro,winrt-xaml,Listview,Listbox,Windows 8,Microsoft Metro,Winrt Xaml,我想定义一个自定义类,它有一个图像和一个文本块 自定义类 <Page Height="100" Width="500" x:Class="SQLite.Custom" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:SQLite"
<Page Height="100" Width="500"
x:Class="SQLite.Custom"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SQLite"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Image Name="img" HorizontalAlignment="Left" Height="67" Margin="10,10,0,0" VerticalAlignment="Top" Width="91"/>
<TextBlock Name="txtBlk" HorizontalAlignment="Left" Margin="177,22,0,0" TextWrapping="Wrap" FontSize="35" VerticalAlignment="Top" Height="45" Width="264"/>
</Grid>
</Page>
我曾尝试过这样做,但在很多情况下都失败了。无法访问
clb.img或clb.txtBlk
我需要一些帮助
谢谢。您没有标记您的问题是与XAML还是与WinJS相关,但让我向您指出一个示例,其中显示了如何在WinJS中创建列表视图项模板:
<div id="regularListIconTextTemplate" data-win-control="WinJS.Binding.Template" style="display: none">
<div class="regularListIconTextItem">
<img src="#" class="regularListIconTextItem-Image" data-win-bind="src: picture" />
<div class="regularListIconTextItem-Detail">
<h4 data-win-bind="innerText: title"></h4>
<h6 data-win-bind="innerText: text"></h6>
</div>
</div>
</div>
这是XAML ListView项目模板的MSDN。@WiniP我还包括了对XAML项目模板的引用。感谢您的回答,我只想将该自定义类添加到我的ListView中。在访问customclass的元素时。
<div id="regularListIconTextTemplate" data-win-control="WinJS.Binding.Template" style="display: none">
<div class="regularListIconTextItem">
<img src="#" class="regularListIconTextItem-Image" data-win-bind="src: picture" />
<div class="regularListIconTextItem-Detail">
<h4 data-win-bind="innerText: title"></h4>
<h6 data-win-bind="innerText: text"></h6>
</div>
</div>
</div>