Binding innerhalb ListView ItemsCollection auf ViewModel Property.

  • WPF

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

    Binding innerhalb ListView ItemsCollection auf ViewModel Property.

    Guten Tag,

    ich habe ein ListView:

    XML-Quellcode

    1. <ListView SelectionMode="Single" ItemContainerStyle="{StaticResource ContainerStyle}" ItemsSource="{Binding Selected.settings}" Background="White" Margin="10,10,10,10" ScrollViewer.HorizontalScrollBarVisibility="Disabled" IsTextSearchEnabled="False" Focusable="False" BorderBrush="{x:Null}">
    2. <ListView.View>
    3. <GridView ColumnHeaderContainerStyle="{StaticResource CustomColumnStyle1}">
    4. <GridViewColumn Width="200" DisplayMemberBinding="{Binding anzeigeName}" />
    5. <GridViewColumn Width="{Binding ActualWidth, RelativeSource = {RelativeSource AncestorType = {x:Type ListView}}}">
    6. <GridViewColumn.CellTemplate>
    7. <DataTemplate>
    8. <ContentControl Content="{Binding}">
    9. <ContentControl.Style>
    10. <Style TargetType="{x:Type ContentControl}">
    11. <Style.Triggers>
    12. <DataTrigger Binding="{Binding type}" Value="3">
    13. <Setter Property="ContentTemplate">
    14. <Setter.Value>
    15. <DataTemplate>
    16. <Grid>
    17. <TypSteuerElemente:DBControl DBFelder="{Binding value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,220,0" Datenbank="{Binding Path=DataContext.Selected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"></TypSteuerElemente:DBControl>
    18. </Grid>
    19. </DataTemplate>
    20. </Setter.Value>
    21. </Setter>
    22. </DataTrigger>
    23. </Style.Triggers>
    24. </Style>
    25. </ContentControl.Style>
    26. </ContentControl>
    27. </DataTemplate>
    28. </GridViewColumn.CellTemplate>
    29. </GridViewColumn>
    30. </GridView>
    31. </ListView.View>
    32. </ListView>


    Dabei geht es um folgende Zeile:

    XML-Quellcode

    1. <TypSteuerElemente:DBControl DBFelder="{Binding value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,220,0" Datenbank="{Binding Path=DataContext.Selected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"></TypSteuerElemente:DBControl>


    Ich möchte die DependencyProperty Datenbank an die Property Selected in dem ViewModel Binden.
    Leider bekomme ich innerhalb der ItemsCollection des Listviews keinen Zugriff darauf, bzw das Binding klappt nicht.

    Ich hoffe Ihr könnt mir helfen.

    Ich bedanke mich.

    MfG Michael