Grid in einem ComboBox Item Template

  • WPF

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von thefiloe.

    Grid in einem ComboBox Item Template

    Hallo liebe Vb-Paradise Community,

    ich habe ein kleines Problem und zwar will der ComboBox Item Inhalt das Grid nicht annehmen.
    Was zur falschen positionierung der Textkörper führt.


    Hier mein Code:

    XML-Quellcode

    1. <ComboBox x:Name="History" Style="{DynamicResource CustomComboBox}" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=ProgressHistoryItems, Mode=TwoWay}" SelectedIndex="{Binding Path=SelectedItemIndex, Mode=TwoWay}" Grid.Column="2" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
    2. <ComboBox.ItemTemplate>
    3. <DataTemplate>
    4. <Grid>
    5. <Grid.ColumnDefinitions>
    6. <ColumnDefinition Width="80*"/>
    7. <ColumnDefinition Width="20*"/>
    8. </Grid.ColumnDefinitions>
    9. <TextBlock Grid.Column="0" Text="{Binding Path=Name}" VerticalAlignment="Stretch" HorizontalAlignment="Left" Width="Auto"/>
    10. <TextBlock Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="Auto">
    11. <TextBlock.Text>
    12. <MultiBinding StringFormat="{}{0}:{1:D2}">
    13. <Binding Path="ElapsedTime.Minutes" />
    14. <Binding Path="ElapsedTime.Seconds" />
    15. </MultiBinding>
    16. </TextBlock.Text>
    17. </TextBlock>
    18. </Grid>
    19. </DataTemplate>
    20. </ComboBox.ItemTemplate>
    21. </ComboBox>

    Vielleicht habt ihr eine Lösung für mein Problem??

    Ich wäre echt sehr Dankbar.

    Beste Grüße,
    Fabien
    Ich sehe jetzt eigentlich keinen Fehler. Hast du vll. ein Bild?
    Aber was ich auf den ersten Blick sehe, müsste dein Code recht sauber geschrieben sein und eigentlich funktionieren.
    Wieso brauchst du eigentlich beim TextBlock das Zeug wie VerticalAlignment


    Opensource Audio-Bibliothek auf github: KLICK, im Showroom oder auf NuGet.