Search code examples
windowsxamlwindows-phone-8

How i can made TextBox like this


enter image description here

How i can made TextBox like this in Windows Phone 8.1


Solution

  • You can create a UserControl that has an Image and a TextBox in it. You'd need to declare a string Text DependencyProperty and a string ImageSource DependencyProperty to data bind to. Your XAML would look like this:

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Image Source="{Binding ImageSource, RelativeSource={RelativeSource 
            AncestorType={x:Type YourPrefix:YourUserControl}}}" />
        <TextBox Grid.Column="1" Text="{Binding Text, RelativeSource={RelativeSource 
            AncestorType={x:Type YourPrefix:YourUserControl}}}" />
    </Grid>
    

    If you're not familiar with creating DependencyPropertys, then you can find out how to do it in the Custom Dependency Properties page on MSDN.