简体   繁体   中英

Combo Box, Fixed Item Header

I have a listview with a dataview view:

 <ListView Name="ListView_DataQuery" SelectionChanged="ListView_DataQuery_SelectionChanged">
    <ListView.View>
        <GridView>

            <GridViewColumn DisplayMemberBinding="{Binding ComputerName}">
                <ComboBox Name="Column1" Background="Transparent" BorderBrush="Transparent" MaxDropDownHeight="800"  Text="Machine Name"
                          SelectedItem="{Binding Filter_ListView_DataQuery}" 
                          AllowDrop="False" IsEditable="True" IsManipulationEnabled="False" IsReadOnly="True" Focusable="False"
                          ItemsSource="{Binding MachineNames}" ForceCursor="True">
                </ComboBox>
            </GridViewColumn>

Bindings are all working, im filtering and everything looks good enough. Problem is that i would like drop down headers for all my columns, i have massaged this combo box to the state where, the combobox header displays a text on userform load. the text in this box is not editable or selectable.

issues i have left over which i cant seem to figure out. When i put my cursor over the text it shows the TextEdit cursor "the I looking one" and the next issue is that when you select an item the text changes to that item selected.

so a drop down list with a fixed header. Is there a better way to do this? Does anyone know how to make a combo box with a fixed header ?

So i didnt get an answer, but i figured it out.

<Style TargetType="GridViewColumnHeader" >
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <DockPanel>
                            <Grid>
                                <ComboBox Background="Transparent" Foreground="Black" BorderBrush="Transparent" MaxDropDownHeight="8000"
                                          Name="ComboBox_DataQuery_SelectedItem"
                                          MinWidth="120" DockPanel.Dock="Right" HorizontalAlignment="Right" 
                                          SelectedItem="{Binding Filter_ListView_DataQuery}" 
                                          SelectedIndex="{Binding FilterIndex_ListView_DataQuery}" 
                                          Drop="ComboBox_GridView_Filter_DropDownClosed"
                                          DropDownOpened="ComboBox_GridView_Filter_DropDownOpen" Uid="{Binding}"
                                          />
                                <Label Margin="0,0,20,0" DockPanel.Dock="Left" HorizontalContentAlignment="Right" 
                                       Background="Transparent" BorderBrush="Transparent" IsHitTestVisible="False"  Focusable="False"
                                       Content="{Binding}"/>
                            </Grid>
                        </DockPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>



        <ListView DockPanel.Dock="Top" Name="ListView_DataQuery" ItemsSource="{Binding ListView_DataQuery}">
            <ListView.View>
                <GridView>

                    <GridViewColumn x:Name="ComputerName" DisplayMemberBinding="{Binding ComputerName}" Header="Computer Name"></GridViewColumn>
                    <GridViewColumn x:Name="Name" DisplayMemberBinding="{Binding Name}" Header="Property Name"></GridViewColumn>
                    <GridViewColumn x:Name="Type" DisplayMemberBinding="{Binding Type}" Header="Property Type"></GridViewColumn>
                    <GridViewColumn x:Name="Value" DisplayMemberBinding="{Binding Value}" Header="Property Value"></GridViewColumn>
                    <GridViewColumn x:Name="Instance" DisplayMemberBinding="{Binding RelPath}" Header="Instance"></GridViewColumn>

                </GridView>
            </ListView.View>
        </ListView>

all that didnt work well was when you clicked an item for filtering, i just had to set the combo box's Selected Index back to -1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM