How to bind to viewmodel property in DataTemplate WP7

Topics: Conventions, UI Architecture
May 19, 2011 at 2:00 PM
Edited May 19, 2011 at 2:01 PM

I'm unable to bind to viewmodel property in DataTemplate. I want to show/hide globally checkboxes in ListBox.

<DataTemplate x:Key="template">

 <CheckBox Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Background="Gray" cal:Message.Attach="[Action Check( $dataContext )]" />

Coordinator
May 19, 2011 at 4:09 PM

There doesn't seem to be anything wrong with this code. Can you provide some more context?

May 19, 2011 at 4:22 PM

 

        <DataTemplate x:Key="template">
            
                <StackPanel Margin="0,0,0,10">
		    <CheckBox Visibility="{Binding IsVisible,  Converter={StaticResource BooleanToVisibilityConverter}}" Background="Gray" cal:Message.Attach="[Action Check( $dataContext )]" />
                    <TextBlock Text="{Binding Text1}" Foreground="#FF837D7D" FontFamily="Segoe WP Semibold" FontWeight="Bold"/>
                    <TextBlock Text="{Binding Text2}" Foreground="#FF747474"/>
                </StackPanel>

        </DataTemplate>

Text1 and Text2 are from current item context. I want IsVisible from view context.