0

ビューモデルにデータをバインドしたコンボックスがあります。

ドロップダウン セルは正しく表示されますが、コンボボックスのテキストブロックは同じように表示されません。

ここに画像の説明を入力

これは私のコンボボックスのxamlです

<ComboBox x:Name="UserComboBox" ItemsSource="{Binding userInfoViewModel.Users}" 
       SelectedItem="{Binding userInfoViewModel.SelectedUser, Mode=TwoWay}"  
           ItemTemplate="{StaticResource UserTemplate}"
           ItemContainerStyle="{DynamicResource CustomUserComboBoxStyle}" 
           HorizontalAlignment="Left" Margin="39.025,217.76,0,186.025" Width="204.975" IsEditable="True" Background="#FFF3F3F3" 
           BorderBrush="{DynamicResource CustomBorder}" 
           Height="27.24" >
</ComboBox>

これは私の UserTemplate です

<DataTemplate x:Key="UserTemplate">
      <StackPanel FlowDirection="LeftToRight"  Orientation="Horizontal">
          <TextBlock Text="{Binding Path=InternalNumber}"></TextBlock>
          <TextBlock Text="{Binding Path=UserName}" ></TextBlock>
      </StackPanel>
</DataTemplate>

と私の CustomUserComboBoxStyle

<Style x:Key="CustomUserComboBoxStyle" TargetType="{x:Type ComboBoxItem}">
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="3,0,3,0"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Setter Property="Background" Value="#646363" />
                            <Setter Property="Foreground" Value="#FFFFFFFF"/>
                            <Setter Property="BorderBrush" Value="#646363"/>
                        </Trigger>
                        <Trigger Property="IsHighlighted" Value="false">
                            <Setter Property="Background" Value="#FFF3F3F3" />
                            <Setter Property="BorderBrush" Value="#FFF3F3F3"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

コンボボックスに、名前と番号ではなく、Digicom.Eventserver.Client.user が表示されるのはなぜですか?

4

2 に答える 2