1

给定以下 XAML:

  <ListView Name="selectedCallees" ItemsSource="{Binding Path=map, RelativeSource={RelativeSource AncestorType=Window},
            Mode=OneWay}" Height="239" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,215,10,0" >
     <ListView.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
        <Style TargetType="ListViewItem">
           <Style.Triggers>
              <DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" Value="True">
                 <Setter Property="IsSelected" Value="True" />
              </DataTrigger>
           </Style.Triggers>
        </Style>
     </ListView.Resources>
     <ListView.View>
        <GridView AllowsColumnReorder="True" ColumnHeaderToolTip="Broadcast call targets">         
           <GridViewColumn Width="120">
              <GridViewColumn.CellTemplate>
                 <DataTemplate>
                    <ComboBox ItemsSource="{Binding Path=extensions, RelativeSource={RelativeSource AncestorType=Window}}"
                              Width="105" IsEditable="True" HorizontalAlignment="Center" Margin="0,0,0,0" BorderThickness="0" SelectedValue="------------"
                              SelectedItem="{Binding Path=Key, Mode=OneWay}" SelectionChanged="chooseExtension_SelectionChanged" >
                       <ComboBox.Resources>
                          <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">15</sys:Double>
                       </ComboBox.Resources>
                    </ComboBox>
                 </DataTemplate>
              </GridViewColumn.CellTemplate>
           </GridViewColumn>  
           <GridViewColumn DisplayMemberBinding="{Binding Path=Value}" Header="Description" Width="305" />
           <GridViewColumn Header="" Width="30">
              <GridViewColumn.CellTemplate>
                 <DataTemplate>
                    <Button Content="X" Height="21" Width="18" Click="Button_Click" Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter1}}" />
                 </DataTemplate>
              </GridViewColumn.CellTemplate>
           </GridViewColumn>
        </GridView>
     </ListView.View>      
  </ListView>

如 ComboBox.Resources 中所述,我可以将 SystemParameters.VerticalScrollBarWidthKey 设置为某个值。我想做的是在 Loaded 事件触发时将其设置为自定义(由 ComboBox_Loaded 处理)。

这是可能的,还是有另一种方法可以选择性地使 ComboBox 下拉箭头消失?

4

0 回答 0