我如何制作这样的 TextBox
How i can made TextBox like this
我如何在 Windows Phone 8.1
中制作这样的文本框
您可以创建一个 UserControl
,其中包含一个 Image
和一个 TextBox
。您需要声明一个 string Text DependencyProperty
和一个 string ImageSource DependencyProperty
来绑定数据。您的 XAML 将如下所示:
<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>
如果您不熟悉如何创建 DependencyProperty
,那么您可以在 MSDN 的 Custom Dependency Properties 页面中找到如何创建。
我如何在 Windows Phone 8.1
中制作这样的文本框您可以创建一个 UserControl
,其中包含一个 Image
和一个 TextBox
。您需要声明一个 string Text DependencyProperty
和一个 string ImageSource DependencyProperty
来绑定数据。您的 XAML 将如下所示:
<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>
如果您不熟悉如何创建 DependencyProperty
,那么您可以在 MSDN 的 Custom Dependency Properties 页面中找到如何创建。