繁体   English   中英

获取网格Winrt中的上一个项目

[英]Get previous item in grid winrt

<Grid x:Name="gridGeneralProperties" HorizontalAlignment="Left" Height="613" Margin="233,5,0,0" Grid.Row="1" VerticalAlignment="Top" Width="437">
    <TextBlock TextWrapping="Wrap" Text="General Properties" FontSize="16" Margin="162,10,18,573"/>
    <TextBlock TextWrapping="Wrap" Text="Name" Margin="10,69,298,521" FontSize="14.667"/>
    <TextBox TextWrapping="Wrap" Text="{Binding Document.DocumentName}" IsReadOnly="True" Margin="144,59,73,520"/>
    <AppBarButton x:Name="appBarButtonEditName" HorizontalAlignment="Left" Label="" Margin="349,39,-12,0" VerticalAlignment="Top" Icon="Edit" Height="75"/>
</Grid>

有没有办法访问网格中的前一个? 在这种情况下,如果用户单击AppBarButton,则我想使以前的TextBox可编辑。 在单击按钮的所有情况下,上一项都是TextBox。

对于您的情况-您知道XAML中的哪个是以前的-您只需命名它即可访问它。

通用解决方案是获取Grid.Children集合中起始元素的索引,而前一个元素将位于索引-1处。

MVVM是要走的路。 我也不确定为什么需要一个按钮来使TextBox可编辑-始终将其保留为可编辑状态,这样可以节省空间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM