使用特定标记查找文本框的值

时间:2017-07-24 14:00:46

标签: c# win-universal-app

我有不同标签的文本框,现在我想获得一个特定的文本框

 <TextBox Name="comment_box" Tag="{x:Bind id}" Width="300"/>

标签的值是动态的,所以在我的按钮中单击

  private void submit_checklist_Click(object sender, RoutedEventArgs e){

    var tagval = this.getval(12) //here i can set value manually

   }


  public int getval(int tagtogetval){
    //here how do i get the 

  var value = (TextBox)comment_box. ///now am stuck here
  return (int)value;  
 }

使用uwp

更新文本框包含在列表视图中,如下所示

                    <ListView Height="600" x:Name="checklist_items" Margin="0, 15,0,20"
                         SelectionMode="None"
                           RelativePanel.AlignBottomWithPanel="True"
                          HorizontalContentAlignment="Stretch"
                          ItemsSource="{x:Bind checklists}"
                           ItemContainerStyle="{StaticResource BorderedItem}"
                          >
                        <ListView.ItemTemplate>
                            <DataTemplate x:DataType="data:ChecklistsModel">
                                <Grid Margin="0,0,0,4">
                                    <StackPanel 
                                        Orientation="Vertical"
                                        Margin="0,0,0,10"
                                                >
                                        <TextBlock Width="680" Text="{x:Bind item}" Margin="0,10,0,0"  FontSize="15" TextWrapping="Wrap" />
                                        <StackPanel Orientation="Horizontal" Margin="0,20,0,0" Name="check_control_area">
                                            <RadioButton  Tag="{x:Bind id}" ClickMode="Press" Click="Yes_Click" Content="Yes" GroupName="{x:Bind id}" Margin="10,0,10,0" />
                                            <RadioButton Tag="{x:Bind id}" ClickMode="Press" Click="No_Click" Content="No" GroupName="{x:Bind id}" Margin="10,0,10,0" />
                                            <TextBox LostFocus="comment_box_LostFocus" Name="comment_box" Tag="{x:Bind id}" Width="300"/>
                                        </StackPanel>

                                    </StackPanel>


                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>

                    </ListView>

0 个答案:

没有答案