Edit Command


Want to know how can i implement EditCommand in Silverlight. My node is using a template that a ListBox. The ItemsSource has been bound to Data.Members Property. Here is the snippet:

<Border BorderThickness="1" BorderBrush="Green" Padding="0,0,0,0" CornerRadius="4" Background="{Binding Path=Part.IsDropOntoAccepted, Converter={StaticResource theBooleanBrushConverter}}" go:Part.DropOntoBehavior="AddsLinkFromNode" go:Part.SelectionAdorned="True" MinWidth="100" MouseLeftButtonDown="Node_MouseLeftButtonDown" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}">

<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

<Grid.RowDefinitions> <RowDefinition MinHeight="22" Height="auto" /> <RowDefinition MinHeight="60" Height="auto" /> </Grid.RowDefinitions> <Border Grid.Row="0" Background="{Binding Path=Data.NodeBackground}" BorderThickness="0.5" BorderBrush="LightGreen" CornerRadius="4,4,0,0">

<TextBlock Text="{Binding Path=Data.Title, Mode=TwoWay}" FontWeight="Bold" go:Part.TextEditable="True" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontFamily="Arial" />


<ListBox Grid.Row="1" Background="Transparent" VerticalAlignment="Stretch" BorderThickness="0" ItemsSource="{Binding Data.Members}">


<DataTemplate><Grid Margin="5,0,4,5" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.345*"/> <ColumnDefinition Width="0.655*"/> </Grid.ColumnDefinitions> <TextBlock Text="Name: " VerticalAlignment="Center" /> <TextBlock Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=TwoWay}" go:Part.TextEditable="True" VerticalAlignment="Center" Margin="5,0,0,0" /> <TextBlock Grid.Row="1" Text="Contact No.:" VerticalAlignment="Center" /> <TextBlock Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding ContactNo, Mode=TwoWay}" go:Part.TextEditable="True" VerticalAlignment="Center" Margin="5,0,0,0" /> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>


</Border>Now when I click on text inside list Item, it is uneditable. what do I have to do to make it editable. And secondly I want to fire Delete Node command explicitly eg. On Rightclick or on a button click the selected node should get deleted.

If GoXam isn’t getting the mouse click event inside the ListBox, I believe it is because the ListBox is catching and handling the mouse events in order to implement selection.

It’s for a completely different purpose, but you might want to look at the InertListBoxItem class that is used in the ListBoxes used by the nodes in the DynamicPorts sample. I haven’t tried it, but it might help you get around the problem that the Diagram isn’t getting any mouse events there.

An alternative would be to implement the in-place text editing entirely within your ListBox ItemTemplate. That way you wouldn’t be depending on any GoXam functionality.

Oh, and to delete the currently selected parts, just call Diagram.CommandHandler.Delete().

Thanks, but why not calling something like this CommandHandler.Edit() to edit any text inside ListBox if I could catch Text’s MouseLeftButtonDownEvent. Althought I tried the same but didn’t succeed. Any suggestions in this context!!