tags:

views:

45

answers:

2

Hi all, I have the XAML like this. (This code is just some part of my source code)

<UserControl x:Class="EmployeeClass"
...............>  
.............
.............
<ListView x:Name="EmployeeList" Width="700" Height="500" Margin="10"  
                              ItemsSource ="{Binding Source={x:Static local:Company.employeeList}}"
                              Background="Black" 
                              ItemTemplateSelector="{DynamicResource myDataTemplateSelector}" Focusable="False"
                              IsSynchronizedWithCurrentItem="True">                            
                        </ListView>
</UserControl>

Here is one of my data template

    <DataTemplate x:Key="SeniorEmployee" DataType="{x:Type local:ListEmployee}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="10">
                            <Image x:Name="ProfilePicture" Source="{Binding Path=ProfilePict}" Stretch="Fill" Width="80" Height="80" VerticalAlignment="Top"></Image>
                            <StackPanel Orientation="Vertical" Margin="5">                                   
                                <TextBlock Text="{Binding Path=Attribution}" Foreground="White" TextWrapping="Wrap" Width="400" VerticalAlignment="Top" HorizontalAlignment="Left"/>  

                        <StackPanel Margin="7,5,0,7">
                                        <UISkripsi3:CommandTextBox Name="AttributionTextBox" HorizontalAlignment="Left" Margin="10,5" Panel.ZIndex="1" 
                                                               BannerText="Add to the attribution" FontSize="{DynamicResource LargeFontSize1}" 
                                                               SpellCheck.IsEnabled="True" Style="{DynamicResource AttributionTextBoxStyle}" 
                                                               TextWrapping="Wrap">
                                        </UISkripsi3:CommandTextBox>
                                        <Button Style="{DynamicResource StandardButtonStyle}" IsEnabled="{Binding ElementName=AttributionTextBox, Path=Text, Converter={StaticResource IsStringNullOrWhitespaceConverter}, ConverterParameter=Inverse}" Click="AttributionButtonClick" Height="22" HorizontalAlignment="Right" Margin="10,4,10,0" Panel.ZIndex="0" CommandTarget="{Binding ElementName=AttributionTextBox}" Content="Show" FontSize="{DynamicResource LargeFontSize1}">
                                        </Button>
                                      </StackPanel>
                    </Grid>
                </DataTemplate>

If user type something in the AttributionTextBox and click the button, there will be a messagebox showing text typed by the user. I have tried http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx and visual tree helper at h*tp://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.aspx

My problem is, I can't find the AttributionTextBox in code behind. I also can't access the EmployeeList Listview because it wasn't generated in the code behind. Can anyone help me to solve the problem?

A: 

What about setting the Binding to TwoWay mode and accessing the Attribution property instead ? This seems much simpler than walking the visual tree.

Timores
I want to access the AttributionTextBox not the Attribution property, when user type something and click the button, the text will be displayed. But, thx for your advice
A: 

I'm having similar problem. Any solution for this problem?

Wandy Wijayanto