I am implementing a user control which has a grid which again contains a grid (lets say sampleGridItem) with button, textblock etc. sampleGridItem is populated with a list in code behind. My goal is when a button is pressed it will disable the button till the operation of button completes. Than it will again enable same button. But the problem is when the button is disabled it changes the focus to the next grid item. Is there anyway to avoid this focus change situation?
This is the sample code,
<Grid>
<Grid x:Name="sampleGridItem>
<Button x:Name="SampleButton"
click="buttonClickEvent" />
<Textblock x:Name="SampleTextBlock"/>
</Grid>
</Grid>
In code behind
private void buttonClickEvent(object sender, RoutedEventArgs e)
{
SampleButton.IsEnabled = false;
// Do something
SampleButton.IsEnabled = true;
}
Update: I think I need to elaborate more, The sampleGridItem is produced from an observable collection, so there are multiple grid items generated in a grid. When clicking the button in one grid item it at first disable the button as a result it changes the focus in next grid item. I am trying to stop this focus change.