これは簡単な質問のようですが、Webで答えを見つけることができませんでした。私が欲しいのは、ユーザーが入ったときにテキストボックスでコンテンツを強調表示することだけです(この例では「価格」または「数量」)。現在、コンテンツを編集するには、最初にダブルクリックする必要があります。コンテンツは、フォーカスが合ったときに自動的に選択される必要があります。これどうやってするの?
ありがとうございました
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="350" Width="479" Name="Window1">
<Window.Resources>
<CollectionViewSource x:Key="MasterView" />
<CollectionViewSource Source="{Binding Source={StaticResource MasterView}, Path='OrderDetails'}" x:Key="DetailView" />
<CollectionViewSource x:Key="CustomerLookup" />
<CollectionViewSource x:Key="ProductLookup" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="42" />
<RowDefinition Height="110" />
<RowDefinition Height="42" />
<RowDefinition Height="147*" />
</Grid.RowDefinitions>
<Grid Grid.Row="1" Name="Grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="146*" />
<ColumnDefinition Width="346*" />
</Grid.ColumnDefinitions>
<StackPanel Name="StackPanel1" >
<Label Height="28" Name="Label1" Width="Auto" HorizontalContentAlignment="Right">ID:</Label>
<Label Height="28" Name="Label2" Width="Auto" HorizontalContentAlignment="Right">Customer:</Label>
<Label Height="28" Name="Label3" Width="Auto" HorizontalContentAlignment="Right">Order Date:</Label>
<Label Height="28" Name="Label4" Width="Auto" HorizontalContentAlignment="Right">Ship Date:</Label>
</StackPanel>
<StackPanel Name="StackPanel2" Grid.Column="1" DataContext="{Binding Source={StaticResource MasterView}}">
<TextBox Height="23" Name="TextBox1" Width="100" Margin="2" HorizontalAlignment="Left" IsReadOnly="True"
Text="{Binding Path=OrderID, Mode=OneWay}"/>
<ComboBox Height="23" Name="ComboBox1" Width="177" Margin="2" HorizontalAlignment="Left"
IsEditable="False"
ItemsSource="{Binding Source={StaticResource CustomerLookup}}"
SelectedValue="{Binding Path=CustomerID}"
SelectedValuePath="CustomerID"
DisplayMemberPath="Name"/>
<TextBox Height="23" Name="TextBox3" Width="100" Margin="2" HorizontalAlignment="Left"
Text="{Binding Path=OrderDate}"/>
<TextBox Height="23" Name="TextBox4" Width="100" Margin="2" HorizontalAlignment="Left"
Text="{Binding Path=ShipDate}"/>
</StackPanel>
</Grid>
<StackPanel Name="StackPanel3" Orientation="Horizontal">
<Button Height="25" Name="btnAdd" Width="Auto" Margin="3">Add Order</Button>
<Button Height="25" Name="btnDelete" Width="Auto" Margin="3">Delete Order</Button>
<Button Height="25" Name="btnPrevious" Width="75" Margin="3">Previous</Button>
<Button Height="25" Name="btnNext" Width="75" Margin="3">Next</Button>
<Button Height="25" Name="btnSave" Width="75" Margin="3">Save</Button>
</StackPanel>
<StackPanel Name="StackPanel4" Orientation="Horizontal" Grid.Row="2">
<Button Height="25" Name="btnAddDetail" Width="Auto" Margin="3">Add Detail</Button>
<Button Height="25" Name="btnDeleteDetail" Width="Auto" Margin="3">Delete Detail</Button>
</StackPanel>
<ListView Grid.Row="3" Name="ListView1"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource DetailView}}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<EventSetter Event="GotFocus" Handler="Item_GotFocus" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="ID" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Path=OrderDetailID}"
Margin="-6,0,-6,0"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="OrderID" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Path=OrderID}"
Margin="-6,0,-6,0"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Product" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox IsEditable="False"
Name="cboProduct"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource ProductLookup}}"
SelectedValue="{Binding Path=ProductID}"
DisplayMemberPath="Name"
SelectedValuePath="ProductID"
Margin="-6,0,-6,0"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Quantity" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Quantity}"
Margin="-6,0,-6,0"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Price" Width="75">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Price}"
Margin="-6,0,-6,0"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>