ComboBox SelectedIndex未显示

时间:2012-08-13 08:06:52

标签: c# wpf combobox selecteditem

我有这样的XAML代码:

<ComboBox Style="{DynamicResource Style_ComboBoxFlags}" SelectedIndex="0">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <controlsModels:CustomInvokeCommandAction Command="{Binding ChangeLanguage}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <ComboBoxItem Style="{DynamicResource Style_ComboBoxItem}">
                <StackPanel Width="41" Height="26">
                    <Path Data="M0,0 L41,0 L41,13 L0,13 z" Fill="White" Height="13" Stretch="Fill" VerticalAlignment="Top"/>
                    <Path Data="M0,0 L41,0 L41,13 L0,13 z" Fill="Red" Height="13" Stretch="Fill" VerticalAlignment="Bottom"/>
                </StackPanel>
            </ComboBoxItem>
            <ComboBoxItem Style="{DynamicResource Style_ComboBoxItem}">
                <Border BorderBrush="{StaticResource BorderGray}" BorderThickness="1" Margin="-1">
                    <Grid>
                        <Path Data="M0,0 L41,0 L41,26 L0,26 z" Fill="Red" Stretch="Fill"/>
                        <Path Data="M0,0 L41,0 L41,8.6666667 L0,8.6666667 z" Fill="Black" Height="8.666666666" Stretch="Fill" VerticalAlignment="Top"/>
                        <Path Data="M0,0 L41,0 L41,8.6666667 L0,8.6666667 z" Fill="Yellow" Height="8.666666666" Stretch="Fill" VerticalAlignment="Bottom"/>
                    </Grid>
                </Border>
            </ComboBoxItem>
        </ComboBox>

除非加载控件后没有显示任何项目,否则一切似乎都能正常工作。但当我将鼠标悬停在窗口中的任何其他控件上时 - 选择正在更新。为什么?我需要随时显示该项目。

0 个答案:

没有答案