0

I'm scanning a document and saving three values.

I want to create a pop-up that will appear after the scan and will consist of 3 text boxes. Each text box will contain by default the scanned value, when I will have the abuilty to edit it by pressing on the text box.

I've looked at the text box properties but found only "read-only" property. Besides that, I really don't have a clue how to start and what to look for.

meanwhile I have this xaml describing the pop-up:

<Popup x:Name="AfterScan" Grid.Row="2">
    <Border  BorderThickness="2" Margin="10" BorderBrush="{StaticResource PhoneAccentBrush}">
        <StackPanel Background="Gainsboro" Width="434" Height="400">
            <TextBlock Text="Bill Details" TextAlignment="Center" FontSize="40" Margin="10,0" Foreground="Black"/>
            <TextBlock Text="Please review Bill Details and click OK when done" FontSize="17" Margin="40,0,10,0" Foreground="Black"/>
            <StackPanel  Orientation="Horizontal" Margin="0,10">
                <TextBox x:Name="test"  Width="100" Margin="10,0,10,0" Foreground="Black" BorderBrush="Black"/>
            </StackPanel>
            <StackPanel  Orientation="Horizontal" Margin="0,10">
                <TextBox x:Name="test2"  Width="100" Margin="10,0,10,0" Foreground="Black" BorderBrush="Black"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0,10">
                <Button x:Name="btn_OK"  Content="OK" Width="215" Margin="110,0,10,0" Click="EnsuredDetails_Click" Foreground="Black" BorderBrush="Black"/> 
            </StackPanel>

        </StackPanel>
    </Border>
</Popup>

I know that If I write a value - I can get it and use it later, but I want the text box to contain my scanned value.

I also saw this article: http://mrbool.com/how-to-build-a-custom-textbox-in-windows-phone/25846

My problem is that the default value of this text box is a string declared in the xaml code, and I need it to be a dynamic parameter:

 <my:DefaultTxt_box Height="103" HorizontalAlignment="Left" Margin="-4,49,0,0"Name="defaultTxt_box1"
                           Text="" D_Text="Enter Your Name" VerticalAlignment="Top" Width="460"FontSize="32" FontFamily="Comic Sans MS" Foreground="#FFFFFF4C">
            <my:DefaultTxt_box.Background>

Can someone please guide me a little?

Thanks a lot!

WiredPrairie
  • 58,954
  • 17
  • 116
  • 143
user1386966
  • 3,302
  • 13
  • 43
  • 72

4 Answers4

1

You have to options to get this done.

Option 1)

You can bind text property of textbox with dynamic value property. for this you can use this link.

Option 2)

You will have three textboxes in xaml of popup.

<TextBox x:Name="test"  Width="100" Margin="10,0,10,0" Foreground="Black" BorderBrush="Black" Text="your default value will go here"/>

<TextBox x:Name="test_2"  Width="100" Margin="10,0,10,0" Foreground="Black" BorderBrush="Black" Text="your default value will go here"/>

<TextBox x:Name="test_3"  Width="100" Margin="10,0,10,0" Foreground="Black" BorderBrush="Black" Text="your default value will go here"/>

Then you can set text property of text boxes from code behind c# code. For this, first you have to get value out from scanned document.

Suppose you have got these values in variables ScannedValue1, ScannedValue2 and ScannedValue3

String ScannedValue1 ; //You will have to assigned values from scanned copy here
String ScannedValue2 ; //You will have to assigned values from scanned copy here
String ScannedValue3 ; //You will have to assigned values from scanned copy here

Then you can utilize these values to assign them to text boxes of pop up.

test.Text = ScannedValue1;
test_2.Text = ScannedValue2;
test_3.Text = ScannedValue3; 

Hope you can get idea from this :)

Naresh Ravlani
  • 1,600
  • 13
  • 28
0

This may be what you're looking for:

Textbox myTxtbx = new Textbox();
myTxtbx.Text = "Enter text here...";

myTxtbx.OnFocus += OnFocus.EventHandle(RemoveText);
myTxtbx.LoseFocus += LoseFocus.EventHandle(AddText);

public RemoveText(object sender, EventArgs e)
{
     myTxtbx.Text = "";
}

public AddText(object sender, EventArgs e)
{
     if(myTxtbx.Text == "")
        myTxtbx.Text = "Enter text here...";
}

Adding placeholder text to textbox

Community
  • 1
  • 1
mildse7en
  • 522
  • 1
  • 8
  • 20
0

Every textBox should have a x:Name property, and just set it in your C# code like this:

myTextBox.Text = 'myScannedValue';

'myTextBox' is your x:Name of TextBoxin XAML. try it.

Chris Shao
  • 8,231
  • 3
  • 39
  • 37
0

Use PhoneTextBox from Windows Phone Toolkit. http://www.geekchamp.com/articles/windows-phone-toolkit-phonetextbox-in-depth

Rajeev Nair
  • 759
  • 8
  • 20