简体   繁体   中英

Access to components (textBox) in pivot Windows phone 8.1

is possible to access to components in Pivot ? I have textBox in pivot and I would like change this text in code behind, but I don't see this component in my code. I tryed set x:FieldModifier="public" but still I don't have acces to this component. Thanks

     <PivotItem  Header="Termíny" Margin="19,23,19,50">
                <Grid>
                    <Grid.RowDefinitions>

                        <RowDefinition Height="*"/>
                        <RowDefinition Height="70"/>
                    </Grid.RowDefinitions>

                    <ListView SelectionMode="None" x:Name="ListBox1" Margin="0,0,-0.167,0.167"
    HorizontalAlignment="Stretch"  IsItemClickEnabled="True"
                        ContinuumNavigationTransitionInfo.ExitElementContainer="True"
   ItemsSource="{Binding}" >
                    <ListView.ItemTemplate>
                        <DataTemplate>

                                <Grid>

                                        <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                <StackPanel Grid.Column="1" Margin="14.5,0,0,0">
                                        <TextBlock x:Name="txtTest" Text="test" Style="{ThemeResource ListViewItemTextBlockStyle}"/>
                                        <StackPanel Orientation="Horizontal">

                                        <TextBlock Text="{Binding jmeno}" Style="{ThemeResource ListViewItemTextBlockStyle}"/>
                                        <TextBlock Margin="10,0,0,0" Text="{Binding prijmeni}" Style="{ThemeResource ListViewItemTextBlockStyle}" />
                                    </StackPanel>

                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding termin}" Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}" />

                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                            <TextBlock Margin="0,0,0,0" Text="{Binding skutecny_termin}" Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}"  />

                                        </StackPanel>
                                </StackPanel>

                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
<Button Content="nacti" Grid.Row="2" Click="Button_Click" />
                </Grid>
            </PivotItem>

由于您的文本块位于数据模板内部,因此唯一的修改方法是使用viewmodel并绑定文本所需的属性,或者,如果不必使用viewmodel,则必须将文本块放置在datatemplate外部,然后可以在代码中访问它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM