"button" with invisible content

Asked

Viewed 244 times

1

There is how to set a content to a button in WPF, but that it is invisible to the user?

  • What is your intention? You may not need to do this. And if you need to, depending on the intention you have a different way.

  • I’m trying to make a naval battle using the buttons and my little knowledge kkkk.

  • @Ayo you could use an array (array)

1 answer

2


You don’t have to do this. Button is button, data is given, it needs to be separate. I don’t even know if I should use a button, but I think the most that should be inside it is a picture, a text that indicates what’s there, but this shouldn’t be used as a datum.

You can do it:

<Button>
    <StackPanel>
        <TextBlock>Texto se achar que deve ter algum</TextBlock>
        <Image Source="submarino.png" />
    </StackPanel>
</Button>

There are cases that can be useful so:

<Button>
   <StackPanel Orientation="Horizontal">
       <Image Source="destroierParte1.png" />
       <Label>Texto aqui</Label>
   </StackPanel>
</Button>

I put in the Github for future reference.

In WPF you can compose in various ways, you have to use creativity.

Obviously it will probably start the source with an image hiding the object to be shown. When it is clicked the image should be changed, perhaps invoking some effects. In the change, you will change the array of data that will control which parts have already been seen and will fire an event when every ship is shown, update score, etc.

Anyway, just giving a few tips, it seems simple, but there are several things that need to happen in a naval battle.

  • got it ... thanks for the help. Do you think you better wear buttons ? how else would you do?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.