好吧,希望你能理解我...
我有一个列表视图。ListView 填充了数据的集合(列表列表),但是 ListView 中的每个项目都有相同的模板(边框、网格、边框、文本块),所以,当我选择一个文本块时,如何获取文本块的文本属性物品 ??
xmlns:vmSegments="using:EC_UsuarioWin8.ViewModels"
<Page.Resources>
<DataTemplate x:Key="ItemTemplateStyleSegment">
<Border Margin="-10,0,0,0" Background="White" >
<Grid Height="120" Width="200">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<Image Source="{Binding SegmentImage}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10"/>
</Border>
<Border Grid.Row="1" >
<TextBlock Text="{Binding SegmentName}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFE0241B" FontSize="20" />
</Border>
</Grid>
</Border>
</DataTemplate>
</Page.Resources>
<Grid>
<Grid.Resources>
<vmSegments:ViewModelSegments x:Key="SegmentCollectionVM" x:Name="SegmentCollectionVM"/>
</Grid.Resources>
<ListView x:Name="ListVIewSegments" ItemsSource="{Binding Source={StaticResource SegmentCollectionVM}, Path= SegmentList}" Grid.Row="1" Margin="20" ItemContainerStyle="{StaticResource ListViewSItemtyleECFood}" ItemTemplate="{StaticResource ItemTemplateStyleSegment}" SelectionChanged="ListViewSegments_SelectionChanged">
</ListView>
</Grid>
我的班级 ViewModelSegments:
public class ViewModelSegments : BindableBase
{
private SegmentsCollection _segmentList = new SegmentsCollection();
public SegmentsCollection SegmentList
{
get { return _segmentList; }
set { SetProperty(ref _segmentList, value); }
}
}
我的班级 SegmentsCollection:
public class SegmentsCollection: ObservableCollection<Segment>
{
}
我的课段:
public class Segment : BindableBase
{
//Propiedad SegmentName
private string Name;
public string SegmentName
{
get { return Name; }
set { SetProperty(ref Name, value); }
}
//Propiedad SegmentPicture
private Uri image;
public Uri SegmentImage
{
get { return image; }
set { SetProperty(ref image, value); }
}
}