2011-11-09 54 views

回答

5

從XAML:

<TextBox Name="myTextBox" TextChanged="OnTextBoxTextChanged" Width="200"> 
    <TextBox.Background> 
    <ImageBrush ImageSource="TextBoxBackground.gif" AlignmentX="Left" Stretch="None" /> 
    </TextBox.Background> 
</TextBox> 

從C#

// Create an ImageBrush. 
ImageBrush textImageBrush = new ImageBrush(); 
textImageBrush.ImageSource = new BitmapImage(new Uri(@"TextBoxBackground.gif", UriKind.Relative)); 
textImageBrush.AlignmentX = AlignmentX.Left; 
textImageBrush.Stretch = Stretch.None; 
// Use the brush to paint the button's background. 
myTextBox.Background = textImageBrush; 

Source

+0

是否也可以抵消文本,以便它不覆蓋圖標? – SharpShade

相關問題