Reputation: 610
<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>
Is there a way to access the previous in a grid? In this case, if a user clicks on the AppBarButton, I want to make the previous TextBox editable. In all instances of where the button is clicked, the previous item will be a TextBox.
Upvotes: 0
Views: 49
Reputation: 31724
In your case - you know which one is previous in your XAML - you can simply name it to access it.
The general solution would be to get the index of the starting element in the Grid.Children
collection and the previous one will be at index - 1.
MVVM is the way to go though. I'm also not sure why you would need a button to make a TextBox
editable - just leave it editable always and you save the space.
Upvotes: 1