TextBlock1 is not declared. It may be inaccessible due to its protection
level
As silly as this sounds im a little stomped at this one. Heres my XAML in
a Win Phone 8 App:
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource
PhoneTextNormalStyle}"/>
<TextBlock Text="Page" Margin="9,-7,0,0" Style="{StaticResource
PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:LongListSelector x:Name="MainLongListSelector"
Margin="0,0,-12,0" ItemsSource="{Binding Items}"
SelectionChanged="MainLongListSelector_SelectionChanged">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock x:Name="TextBlock1"
HorizontalAlignment="Left" TextWrapping="Wrap"
VerticalAlignment="Top"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>
</Grid>
Ive searched around but i dont know why i cant write code against the
TextBlock1 control in code behind. When i type TextBlock1.Text= .... i get
the error TextBlock1 is not declared. It may be inaccessible due to its
protection level. but i cant see how its private?
All im trying to do is add a textblock assign some content to it and then
that selected value is then passed across another page to perform relevant
action.
In addition as soon as i remove it outside of the PhoneListSelector i can
access it!!
No comments:
Post a Comment