locked
Declaring a string variable to a Textblock

    Question

  • I might be a bit stupid asking this question. But i have not found anything on the net as of yet with my problem. I have a windows app, a listview displaying Texblocks with names in them and is loaded from a xml file. Here is the xaml code.

    <ListView x:Name="listMyLoans" RenderTransformOrigin="0.446,0.54" Margin="10,150,1052,10" Grid.RowSpan="2">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="300" Height="100" >
                            <TextBlock x:Name="tbTitle" Text="{Binding Title}"></TextBlock >
                            <TextBlock x:Name="tbMediaIndex" Text="{Binding MediaIndex}" Visibility="Collapsed"/>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

    and i need to declare it like to so in code behind. string strMediaIndex = tbMediaIndex.Text; Something like this but does not work, somehow does not see the TextBlock at all.

    Thanks

    Thursday, March 6, 2014 9:04 AM

Answers

All replies