BindingActions In an ItemsControl

Jan 11, 2011 at 9:31 PM
Edited Jan 11, 2011 at 9:31 PM

I am having an issue binding Actions in an ItemControl. Using the conventions the controls are getting set correctly, but the actions sometimes don't get applied and sometimes they do.  Below is the xaml for the ItemsControl.  I allow the user to add new Cities at run time, but the ZipCodeLookup button does not gets it action set sometimes after more than one city has been added.

	<ItemsControl Name="Cities">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Controls:LsvExpander IsExpanded="True" Micro:Bind.Model="{Binding}">                            
                            <Grid>                                                                
                                        <StackPanel>
                                            <TextBlock Text="City, State, Zip" />
                                            <Button x:Name="ZipCodeLookup" Margin="0 0 8 0" Height="21" IsTabStop="False" >
                                                <Image Source="/GPS.Client;component/Images/search.png" />
                                            </Button>
                                            <Controls:CasingTextBox x:Name="City" MaxLength="50"  />
                                            <Controls:LsvComboBox x:Name="StateOptions" />
                                            <Controls:LsvMaskedTextBox x:Name="Zip" />
                                        </StackPanel>                                                                        
                            </Grid>
                        </Controls:LsvExpander>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

 

I think I have tracked down the issue to the ViewModelBinder BindActions method.  The line below returns the first of default element from the namedElements, but in my case there are multiple elements in this collection with 'ZipCodeLookup'.  If this method returns an element that has already been bound then it won't get the action applied to it.  Is there anything I am doing wrong on my side that would cause this?  If not, what is the best way to handle this?  

 

var foundControl = namedElements.FindName(method.Name);


Thanks in advance,

Mike

 

Coordinator
Jan 11, 2011 at 10:07 PM

It's a bit hard to diagnose. Can you send me a sample application that reproduces the problem. You can send it to robertheisenberg at hotmail dot com

Jan 12, 2011 at 1:26 AM

Rob,

 

You have mail.  Let me know if there is anything else I can do.

 

Thanks,

Mike