Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data bindings in Data Template not working

I have UserControl to do filtering for several presentations, which in turn has a ContentControl. The content are the individual filtering controls that vary among the presentations.

The scheme works as intended visually, but the data bindings do not. There are no data binding errors in output. The DataContext is from a view model call PimMasterVm, which otherwise seems correctly wired (ie, the status of 5 avalable people, etc)

Can someone help me trouble shoot this?

Cheers,
Berryl

Filtering Control

enter image description here

<Grid>
    <Border Style="{StaticResource FilterPanelBorderStyle}">
        <StackPanel Orientation="Horizontal" x:Name="myFilterPanel" >
            <ContentControl x:Name="ctrlFilters" 
                            ContentTemplate="{Binding Path=FilterContentKey, Converter={StaticResource filterTemplateContentConv}}" />
            <Button x:Name="btnClearFilter" Style="{StaticResource FilterPanelClearButtonStyle}" />
            <Label x:Name="lblStatus" Style="{StaticResource FilterPanelLabelStyle}" Content="{Binding Status}" />

        </StackPanel>
    </Border>

</Grid>

Data Template (resource)

<DataTemplate x:Key="pimFilterContent">
    <StackPanel Orientation="Horizontal" >
        <cc:SearchTextBox x:Name="stbLastNameFilter" 
            Style="{StaticResource FilterPanelSearchTextBoxStyle}"
            Text="{Binding Path=LastNameFilter, UpdateSourceTrigger=PropertyChanged}" 
                        />
        <cc:SearchTextBox x:Name="stbFirstNameFilter" 
            Style="{StaticResource FilterPanelSearchTextBoxStyle}"
            Text="{Binding Path=FirstNameFilter, UpdateSourceTrigger=PropertyChanged}" 
                        />
    </StackPanel>
</DataTemplate>
like image 755
Berryl Avatar asked Jan 19 '26 14:01

Berryl


1 Answers

There is current view model in DataContext of the "ctrlFilters" ContentControl, bind it to Content property:

...

    <ContentControl x:Name="ctrlFilters" 
                    Content="{Binding}"
                    ContentTemplate="{Binding Path=FilterContentKey, Converter={StaticResource filterTemplateContentConv}}" />

...    
like image 115
Vladimir Dorokhov Avatar answered Jan 21 '26 08:01

Vladimir Dorokhov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!