Hide the template elements in code-behind file - windows-phone-7

I have a LongListHeaderTemplate that consists of a list and a button. You will see how are they distributed in the code below. My problem is that I need sometimes hide button in code-behind file. How I can do that?!
XAML:
<toolkit:LongListSelector Grid.Row="1" ListHeader="{Binding EpsLaterItems}" IsFlatList="True" ItemsSource="{Binding EpsItems}" x:Name="EPS" SelectionChanged="EPS_SelectionChanged_1">
<toolkit:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding ImageUrl, Converter={StaticResource BmpConverter}}" Width="100" Height="100" VerticalAlignment="Top" Margin="0,10,18,0"/>
<StackPanel Margin="0,0,0,20" Width="300">
<TextBlock Text="{Binding Date, ConverterCulture=ru-RU, StringFormat=f}"
FontSize="22" FontWeight="Bold" Foreground="#FFD65B2D" />
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" FontSize="22" Foreground="Aqua" />
</StackPanel>
</StackPanel>
</DataTemplate>
</toolkit:LongListSelector.ItemTemplate>
<toolkit:LongListSelector.ListHeaderTemplate>
<DataTemplate>
<StackPanel>
<ListBox x:Name="listbox1" ItemsSource="{Binding}" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding ImageUrl, Converter={StaticResource BmpConverter}}" Width="100" Height="100" VerticalAlignment="Top" Margin="0,10,18,0"/>
<StackPanel Margin="0,0,0,20" Width="300">
<TextBlock Text="{Binding Date, ConverterCulture=ru-RU, StringFormat=f}"
FontSize="22" FontWeight="Bold" Foreground="#FFD65B2D" />
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" FontSize="22" Foreground="Aqua" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="footerEpsLater" Content="more..."
FontSize="30" Foreground="SteelBlue" Style="{StaticResource StyleForButton}" BorderBrush="#FFFF2121"/>
</StackPanel>
</DataTemplate>
</toolkit:LongListSelector.ListHeaderTemplate>
<toolkit:LongListSelector.ListFooterTemplate>
<DataTemplate>
<Button Content="more..." FontSize="30" Foreground="SteelBlue" Click="footerEPS_Click_1" Style="{StaticResource StyleForButton}"/>
</DataTemplate>
</toolkit:LongListSelector.ListFooterTemplate>
</toolkit:LongListSelector>
If i do like this footerEpsLater.Visibility = Visibility.Collapsed; I get the error: footerEpsLater does not exist in this context

Related

How can i make this listBox items stretch Verticaly?

__________________________
__________Item1____________
__________Imemnumber2_____
__________Item3____________
__________________________
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="MainListBox" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="MainListBox_SelectionChanged" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="10">
<Image Source="{Binding Image}" Stretch="None"/>
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
how can I do that?
____________________________
___________Item1_____________
_________Imemnumber2________
___________item3_____________
____________________________
Try to set the TextAlignment property of the TextBox
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" TextAlignment="Center"/>
UPDATE:
Try to fix the width of the TextBlock as shown below
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" TextAlignment="Center" Width="400"/>

windows phone 7 observablecollection in listitem

I have an ObservableCollection<testItem> and every testItem has another ObvervableCollection<testData>.
Know for every testData I want a ListItem with some Data of the testItem and from testData. At the moment I set the ObservableCollection<testItem> as ItemsSource of the List but than I get only the first item of the itemsData.
What can I do?
UPDATE:
xaml:
<ListBox Name="ResultList" ItemsSource="{Binding TankstellenItem}" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF3AACDF" BorderThickness="4">
<StackPanel Orientation="Horizontal"
Background="White"
UseLayoutRounding="True" Tap="ItemIsClicked">
<StackPanel Width="130" Orientation="Vertical" Margin="0,0,0,0">
<Border BorderThickness="2"
Background="#FF3AACDF" BorderBrush="White">
<TextBlock Text="{Binding PriceBigDigits}"
FontFamily="Assets/Font.ttf#LCD"
FontSize="25" TextAlignment="Center" />
</Border>
<TextBlock Text="{Binding FuelType}"
TextAlignment="Center"
FontSize="15" Foreground="Black"/>
<TextBlock Text="{Binding UpdateDate}"
TextAlignment="Center"
FontSize="15" Foreground="Black" />
<TextBlock Text="{Binding DistanceString}"
TextAlignment="Center"
FontSize="15" Foreground="Black"/>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="10,0,0,0" Width="400">
<TextBlock Text="{Binding Title}"
FontSize="30" FontWeight="Bold" Foreground="Black"/>
<TextBlock Text="{Binding Address}" FontSize="20" Foreground="Black" />
<TextBlock Text="{Binding PLZCity}" FontSize="20" Foreground="Black" />
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
than I have the testItem:
public testItem{
DistanceString (string),
Title (string),
Addresse (string),
PLZCity (string),
itemDates (ObservableCollection<itemData>)}
And the itemData:
public itemData{
PriceBigDigits (string),
FuelType (string),
UpdateDate (string)
If I understand you correctly, you may want to bind the itemDates to a ItemsControl's ItemsSource property. So wrap your second StackPanel within the DataTemplate of an ItemsControl.

Windows Phone: how to disable touch scrolling in ScrollViewer (Listbox)?

i have a scrollviewer with a listbox inside: i need to disable the vertical scroll by touch, how can i?
In other words, the user can't scroll with the touch (i have put buttons, but this is another story).
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" x:Name="imagesScrollview" Width="480" Height="595" Margin="0,112,0,63">
<ScrollViewer.RenderTransform>
<CompositeTransform/>
</ScrollViewer.RenderTransform>
<ListBox Name="listavideo" Height="595" Width="480">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Width="470" Height="146" Background="White" BorderBrush="#346699" Click="apri_video" Name="{Binding Mylink}" Margin="5,0,5,0" Padding="5">
<Button.Content>
<StackPanel Orientation="Horizontal" Width="470">
<Image Source="{Binding Thumbnail}" Width="160" HorizontalAlignment="Left" VerticalAlignment="Top" />
<StackPanel Orientation="vertical" Width="285" Margin="0,0,0,0" Height="146">
<StackPanel Orientation="Horizontal" Width="275" Margin="0,0,10,0">
<TextBlock Width="275" FontSize="18" Text="{Binding Title}" Foreground="#34638f" TextWrapping="Wrap" />
</StackPanel>
<StackPanel Orientation="Horizontal" Width="275" Margin="0,0,10,0">
<TextBlock Width="275" FontSize="14" Text="{Binding Description}" Foreground="#51504e" TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
</StackPanel>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
Thanks.
<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" Name="listavideo" Height="595" Width="480" >
<ListBox.ItemTemplate>
...

Getting control from backend in wp7

I am binding a Pivot from backend.
The xaml for my Pivot is:
<controls:Pivot Name="MainPivot" Visibility="Collapsed">
<controls:Pivot.Background>
<ImageBrush ImageSource="Images/ItemBrowse.png"></ImageBrush>
</controls:Pivot.Background>
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock FontSize="38" Text="{Binding title}" Foreground="White"/>
</DataTemplate>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate>
<ScrollViewer Name="scroll" Margin="-12" Background="LightGray" VerticalScrollBarVisibility="Auto">
<StackPanel>
<controls:PivotItem Name="pvtItemPrice" >
<StackPanel Orientation="Vertical">
<TextBlock Text="Price" Foreground="Black" FontWeight="Bold" FontSize="28" />
<TextBlock Text="{Binding price}" FontSize="22" Foreground="DarkCyan"/>
</StackPanel>
</controls:PivotItem>
<Border BorderThickness="2" BorderBrush="White" Height="3" Width="470"/>
<controls:PivotItem Name="pvtItemDescription" >
<StackPanel Orientation="Vertical">
<TextBlock Text="Description" Foreground="Black" FontWeight="Bold" FontSize="28" />
<TextBlock Text="{Binding description}" Foreground="Gray" FontSize="22" Width="460" TextWrapping="Wrap"/>
</StackPanel>
</controls:PivotItem>
<Border BorderThickness="2" BorderBrush="White" Height="3" Width="470"/>
<controls:PivotItem Name="pvtItemLocation" >
<StackPanel Orientation="Vertical">
<TextBlock Text="Location:" Foreground="Black" Padding="5" FontWeight="Bold" FontSize="28" />
<Grid >
<StackPanel>
<TextBlock Text="{Binding location}" FontSize="22" Foreground="Brown" Width="460" TextWrapping="Wrap" />
<Button BorderBrush="Transparent" Foreground="Yellow" Name="btnShowMap" Width="370" Content="View in Map" Click="btnShowMap_Click" Height="100">
<Button.Background>
<ImageBrush ImageSource="Images/ImgBtns.png" />
</Button.Background>
</Button>
</StackPanel>
</Grid>
</StackPanel>
</controls:PivotItem>
</StackPanel>
</ScrollViewer>
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
But I have to show or hide the btnShowMap according to the user value. But I cannot get the control from backend. Is there anyway I can get the solution for this.
If you have the markup above within a page, you should find that Visual Studio will have generated a btnShowMap field for you. Simply navigate to the code-behind for this file and you will find it.

How Can i set List Box with in A pivot

my problem is how can i set listbox which has itemtemplate ,and it also itemteplate of pivot
.i don't have any idea to doing this but it is a need of my project .one another is how to set pivot header . i m trying to do something like that
<controls:Pivot Height="779" Name="m" >
<controls:Pivot.Background>
<ImageBrush ImageSource="/WindowsPhoneApplication7;component
/Images/S.jpeg" />
</controls:Pivot.Background>
<!--<controls:PivotItem Name="all" >-->
<controls:Pivot.ItemTemplate>
<DataTemplate>
<ListBox Height="450" HorizontalAlignment="Stretch" Margin="8,6,0,0" Name="listBox1" VerticalAlignment="Stretch" Background="#00537393" Width="445" >
<ListBox.ItemTemplate >
<DataTemplate >
<Border BorderBrush="Black" CornerRadius="8" BorderThickness="1" HorizontalAlignment="Stretch" Name="border">
<Grid HorizontalAlignment="Stretch" Name="grid1" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="0*" />
<RowDefinition Height="100*" />
</Grid.RowDefinitions>
<Image Height="78" HorizontalAlignment="Left" Margin="13,12,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="92" Grid.Row="1" Source="{Binding ImageSource}" />
<TextBlock Foreground="White" Height="80" HorizontalAlignment="Left" Margin="111,12,0,0" Name="textBlock1" Text="{Binding Title}" VerticalAlignment="Top" Width="280" TextWrapping="Wrap" Grid.Row="1" />
<Image Grid.Row="1" Height="75" HorizontalAlignment="Left" Margin="380,12,0,0" Name="image2" Stretch="Fill" VerticalAlignment="Top" Width="73" Source="/WindowsPhoneApplication7;component/Images/appbar.transport.play.rest.png" />
<TextBlock Foreground="White" Grid.Row="1" Height="20" HorizontalAlignment="Left" Margin="111,88,0,0" Name="textBlock2" Text="{Binding date}" VerticalAlignment="Top" Width="190" FontSize="11" />
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</controls:Pivot.ItemTemplate>
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="hiii" TextWrapping="Wrap" FontSize="0" Foreground="White" />
</DataTemplate>
</controls:Pivot.HeaderTemplate>
</controls:Pivot>
You can set the header of a Pivot control to pretty much anything since it is an object. To set it to an image instead of a default title set the Title to "" and do this in the constructor of your page:
YourPivotControl.Title = new Image { Width = 400, Source = new BitmapImage(new Uri("/someImage.png", UriKind.Relative)) };
Did you take a look at the default pivot page setup by visual studio? They do exactly what you're looking for:
<!--Pivot Control-->
<controls:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<controls:PivotItem Header="first">
<!--Double line list with text wrapping-->
<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="78">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PivotItem>

Resources