-1

I need to create a button similar like below, it is a textbox and a button combined, you can click "Get Code" button and you will receive a SMS text with the code, then you can input the code in the textbox.

textbox and a button

anyone can help? Hi, my current code is quite simple.

<Button
    Grid.Row="2"
    Grid.Column="0"
    HorizontalOptions="Center"
    Text="Get Code"
    FontFamily="{ StaticResource IconsFontFamily }"
    Style="{ StaticResource CircleActionButtonFlatStyle }"
    micro:Message.Attach="[Event Clicked] = [Action SendVerifyCodeAsync()]"/>

<Entry
    Grid.Column="1"
    Grid.Row="2"
    Grid.ColumnSpan="2"
    VerticalOptions="Center"
    HorizontalOptions="FillAndExpand"
    Text="{Binding Code}"
    Placeholder="Send Code" />
5
  • 1
    This would be a combination of a text box & button wrapped by a border. You need to post your attempted WPF code before requesting help. Commented Aug 8, 2019 at 19:49
  • 1
    Also if you need help with sending SMS you have to show us what have you tried by showing us the code that you've already written. And then explaining what exactly is not working. Commented Aug 8, 2019 at 20:04
  • Hi Bizhan, the SMS function is working, I just don't know how to rewrite the xaml. Hi Jeff, I have edited my question and attached my current code Commented Aug 9, 2019 at 5:47
  • I think you have a good start. You need to wrap both controls with a rounded border. Check this out for some ways to do this: wpf border with rounded corners. You will probably need to create a button with rounded corners. If you search SO you should find ways to do this. Commented Aug 9, 2019 at 6:24
  • In order to combine the button and textbox into one control, you will need to create a UserControl. Here is an example of creating and using a UserControl: UserControl or you can create the more feature rich but more complicated CustomControl. An example is here: CustomControl Commented Aug 9, 2019 at 20:19

1 Answer 1

0

Has people said in comments, you need to wrap it in borders. With this example, you just need to change the color for the ones you want, and then you can set Click events in the respective borders to make them act like buttons and do the respective actions. You can add the code micro:Message.Attach="[Event Clicked] = [Action SendVerifyCodeAsync()]" to the respective border.

Code:

<Border BorderBrush="Black" BorderThickness="1" Margin="10" CornerRadius="15">
        <Grid Margin="-1">
            <TextBox TextWrapping="Wrap" Text="Input code" Background="{x:Null}" BorderBrush="{x:Null}" HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Center"/>
            <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Right" CornerRadius="15" Background="#FF39D3D3">
                <TextBlock TextWrapping="Wrap" Text="Get Code" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0"/>
            </Border>
        </Grid>
    </Border>

Example:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.