How can I prevent a user to click a button more than once
-
Hi When the button is clicked it changes to another page (UserControl), but if they click the button fast a couple of times it crashes. That is because the service isn't finished with getting data from the database, which the other pages need. I don't want to use IsEnabled=false, is there another way? Thanks Fia
-
Hi When the button is clicked it changes to another page (UserControl), but if they click the button fast a couple of times it crashes. That is because the service isn't finished with getting data from the database, which the other pages need. I don't want to use IsEnabled=false, is there another way? Thanks Fia
Why do you not want to do IsEnabled=false? An alternative could be to set a flag when you click the button the first time and reset it when the service has finished getting data; then it wouldn't matter whether or not the user multipresses the button, you won't make the call until the flag says it's okay to do so.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Why do you not want to do IsEnabled=false? An alternative could be to set a flag when you click the button the first time and reset it when the service has finished getting data; then it wouldn't matter whether or not the user multipresses the button, you won't make the call until the flag says it's okay to do so.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Hi Thanks for your reply But it doesn't work with IsEnabled, I use that button to navigate to a different page, and the button is the same for every page. In one page the user writes the his username and password. If It's right I get the data from that user and move on to a different page when that button is clicked. In another page the users can choose someting from a combobox, when that is choosen and the button is clicked, the data is fetched regarding what was choosen in the combobox. I tried to use IsEndabled=false, but if the user clicks several times, it navigates several pages. It seems like the the button clicks are saved and when the button's IsEnabled=true, it moves the count that the button was clicked. Please help Fia
-
Hi Thanks for your reply But it doesn't work with IsEnabled, I use that button to navigate to a different page, and the button is the same for every page. In one page the user writes the his username and password. If It's right I get the data from that user and move on to a different page when that button is clicked. In another page the users can choose someting from a combobox, when that is choosen and the button is clicked, the data is fetched regarding what was choosen in the combobox. I tried to use IsEndabled=false, but if the user clicks several times, it navigates several pages. It seems like the the button clicks are saved and when the button's IsEnabled=true, it moves the count that the button was clicked. Please help Fia
You could always change it's visibility so that it can't be clicked, and only make it visible when it's the right time to do so.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
You could always change it's visibility so that it can't be clicked, and only make it visible when it's the right time to do so.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Easiest way is just to mask the button. Put a rectangle in the same container that is the width/height of the button and make it transparent. When inside grids, etc, order matters - the rectangle should be represented AFTER the button so it is in the foreground. By default, set the visibility to collapsed. When the user clicks, set it to visible until you are done initializing, then collapse it again. It will mask any clicks or UI events but not fudge the UI.
<Grid>
<Button/>
<Rectangle Fill="Transparent"/>
</StackPanel>Jeremy Likness
Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces
Blog: C#er : IMage