Whats Going On
Whats Going On

Reputation: 1387

how to Give color of a ListBox in windows phone 8 when Backgroud is white? with a image Button

i am new to windows phone development,.. So i am preparing an application in that i given Background Color as white for every page.. in my app i added a search so that user can search data using two text Box..

In that I have given Bg color as white and foreground Color as black.. in that TextBlock is Viable But TextBox are not Visable they are mixing in background...

This is My xaml fiel..

<Grid x:Name="LayoutRoot" Background="White">
    <StackPanel Margin="10,114,10,311">
        <TextBlock Text="Enter Name"
                   TextWrapping="Wrap" 
                   Tap="TextBlock_Tap"
                   Foreground="Black" />

        <TextBox x:Name="Enter Name Field"
                   GotFocus="TextBox_GotFocus" 
                   LostFocus="TextBox_LostFocus"
                   Foreground="RosyBrown" Height="46" Margin="27,0,56,0" />

        <TextBlock Text="Enter A Model number" 
                   TextWrapping="Wrap"  
                   Tap="TextBlock_Tap"
                   Foreground="Black"/>

        <TextBox x:Name="Enter A Model number Field" 
                   GotFocus="TextBox_GotFocus" 
                   LostFocus="TextBox_LostFocus"
                   Foreground="RosyBrown" Height="46" Margin="27,0,56,0" />

    </StackPanel>
</Grid>

Sorry i want to add a Image Button also i tried....

i want it like this enter image description here

Upvotes: 1

Views: 164

Answers (3)

Praveen
Praveen

Reputation: 267

Use your textbox surrounded with border, since you are using a white background.I think below code may help you to get an idea.

<Border  BorderThickness="1" Grid.Row="2" Name="brdUsrName"  HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="60" Background="Black">
<TextBox Name="txtUserName"  Margin="-10,-10,-10,-10"  />
</Border>

Upvotes: 1

Jaihind
Jaihind

Reputation: 2778

This may help you.

<Grid Grid.Row="1" Background="White">
  <StackPanel Margin="10,114,10,311">
   <TextBlock Text="Enter Name"
                   TextWrapping="Wrap" 
                   Tap="TextBlock_Tap"
                   Foreground="Black" />

    <TextBox x:Name="Enter Name Field"
                   GotFocus="TextBox_GotFocus" BorderBrush="Gray" BorderThickness="2"
                   LostFocus="TextBox_LostFocus"
                   Foreground="RosyBrown" Height="46" Margin="27,0,56,0" />

     <TextBlock Text="Enter A Model number" 
                   TextWrapping="Wrap"  
                   Tap="TextBlock_Tap"
                   Foreground="Black"/>

     <TextBox x:Name="Enter A Model number Field" 
                   GotFocus="TextBox_GotFocus" 
                   LostFocus="TextBox_LostFocus" BorderBrush="Gray" BorderThickness="2"
                   Foreground="RosyBrown" Height="46" Margin="27,0,56,0" />

     <Image Height="40" Width="150" Source="your image path" Tap="Image_tap" />

     </StackPanel>
 </Grid>

Upvotes: 2

deeiip
deeiip

Reputation: 3379

add Background="Black" (or whatever color you want) in all your TextBox. For that what you have shown use BorderBrush="Black", decrease the border thickness if you need to. Yes, you can add a image button, use a image as your button background.

<Button>
     <Button.Background>
            <ImageBrush Source="your_file.jpg" Stretch="Fill"/>
     </Button.Background>
</Button>

Note: It is not a good idea to write x:Name value with spaces. what you write in x:Name ultimately become a variable name of type TextBox (in this case) and c# doesn't permit variable name with space, So just delete the spaces and use x:Name="Enter_A_Model number_Field" or simply x:Name="EnterAModelNumberField"

Upvotes: 1

Related Questions