locked
How to toggle checkboxed listitems in a listbox RRS feed

  • Question

  • I have a Popup that normally contains a listbox of list items that I populate by setting the ItemsSource to an array using a trigger.  I have a case where I'd list the list to contains checkboxes instead of just a list.   I prefer to keep my Popup definition generic and just want to set properties in the trigger to change the list to contain checkboxes.   I'm not seeing a property I can set either on the ListBox or ListItems that will display the checkbox?

    Define the arrays like this...

    			<x:Array x:Key="FilterType" Type="System:String">
    				<System:String>Peak</System:String>
    				<System:String>Low Shelf</System:String>
    				<System:String>High Shelf</System:String>
    				<System:String>Low Pass</System:String>
    				<System:String>High Pass</System:String>
    			</x:Array>


    Trigger the button like this...

    			<Button x:Name="FilterType" Content="Peak Filter" HorizontalAlignment="Left" Height="38.043" Style="{DynamicResource Button-Sketch}" VerticalAlignment="Top" Width="253" RenderTransformOrigin="2.636,0.5" Margin="44,220,0,0" FontWeight="Bold">
    			<i:Interaction.Triggers>
    				<i:EventTrigger EventName="Click">
    					<ei:ChangePropertyAction TargetName="PickList" PropertyName="ItemsSource" Value="{DynamicResource FilterType}" />
    					<ei:ChangePropertyAction TargetName="PopupMenu" PropertyName="PlacementTarget" Value="{Binding ElementName=FilterType}" />
    					<ei:ChangePropertyAction TargetName="PopupMenu" PropertyName="IsOpen" Value="True" />
    				</i:EventTrigger>
    			</i:Interaction.Triggers>

    What I'd like to do is set a property on the Popup Listbox that enables checkboxes for the listitems. Is this even possible?

    Popup menu defined here...

    		<Popup Name="PopupMenu" Placement="Mouse" IsOpen="False" StaysOpen="False"  Grid.Row="1"  PopupAnimation="Fade" >
    			<Grid>
    				<Grid.Effect>
    					<DropShadowEffect Color="Black" Opacity="0.5"/>
    				</Grid.Effect>
    				<pc:SketchRectangleUC  Style="{DynamicResource Rectangle-Sketch}" BorderThickness="2" BorderBrush="Black"/>
    				<ListBox x:Name="PickList" ItemsSource="{DynamicResource FilterType}" SelectedIndex="0" Style="{DynamicResource ListBox-Sketch}" BorderThickness="2" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,10,10" >
    					<ListBox.ItemContainerStyle>
    						<Style TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem-Sketch}">
    							<Setter Property="FontSize" Value="32" />
    						</Style>
    					</ListBox.ItemContainerStyle>
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="SelectionChanged">
    							<ei:ChangePropertyAction TargetName="PopupMenu" PropertyName="IsOpen" Value="False" />
    						</i:EventTrigger>
    						<i:EventTrigger EventName="PreviewMouseLeftButtonDown">
    							<ei:ChangePropertyAction TargetName="PopupMenu" PropertyName="IsOpen" Value="False" />
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    				</ListBox>
    			</Grid>
    		</Popup>



    Jeff Davis

    Friday, April 19, 2013 9:20 PM

All replies

  • Lots of views but no ideas?


    Jeff Davis

    Saturday, April 20, 2013 8:24 PM