我创建了一个透视控件,通过使用绑定数据来显示我的数据库中的所有数据。枢轴控件的代码如下所示。和这里的 UI 视图:照片
我想解决这个问题:在我点击列表框的一个项目(枢轴控件)后,我会得到项目的名称。
注意:所有控件都没有名称 (x:name)。我正在尝试使用 Tag="{Binding CHUPHONG}" 替换 x:name。
你能告诉我解决这个问题的方法吗?或者我错在哪里?非常感谢!
<controls:PivotItem Header="PHÒNG CHƠI" FontSize="19" Margin="0" Background="{x:Null}">
<ListBox x:Name="listDSPhong">
<ListBox.ItemTemplate>
<DataTemplate>
<toolkit:WrapPanel Height="120" Width="480" Margin="0,10,0,20">
<Image HorizontalAlignment="Left" Height="120" VerticalAlignment="Top" Width="120" Source="/LuanVanDeMo;component/xephinhlogo.png"/>
<TextBlock Margin="4,44,-98,44" TextWrapping="Wrap" Text="Chủ phòng:" HorizontalAlignment="Left"/>
<TextBlock Height="32" Margin="0,5,-98,0" TextWrapping="Wrap" Text="Tên phòng:" VerticalAlignment="Top" HorizontalAlignment="Left" Width="98"/>
<TextBlock Margin="0,0,-98,4" TextWrapping="Wrap" Text="Số lượng:" Height="32" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="98"/>
<TextBlock Margin="102,44,-242,44" TextWrapping="Wrap" Text="{Binding TENPHONG}" Width="140" Height="32" HorizontalAlignment="Left"/>
<TextBlock Height="32" Margin="102,5,-242,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="{Binding CHUPHONG}" Width="140" HorizontalAlignment="Left"/>
<TextBlock Margin="102,0,-134,4" TextWrapping="Wrap" Height="32" VerticalAlignment="Bottom" Text="{Binding SOLUONG}" Width="32" HorizontalAlignment="Left"/>
<Image HorizontalAlignment="Left" Width="50" Source="/LuanVanDeMo;component/Images/Buttons/lock.png" Margin="285,35,0,35" Height="50"/>
</toolkit:WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PivotItem>
</controls:Pivot>