Color picker in listpicker using - windows-phone-8

I am trying to use color picker on Windows Phone 8, but I cannot see colors. I do not understand where I am making a mistake.
This is my PivotPage code:
string[] colorNames =
{
"GreenYellow","Lime","Chartreuse","LimeGreen","SpringGreen","LightGreen"
}
uint[] uintColors =
{
0xFFFFFF00,0xFFFFE135,0xFFFFFF66,0xFFF8DE7E,0xFF008000,0xFF008A00
}
List<ColorItem> item = new List<ColorItem>();
for (int i = 0; i < 6; i++)
{
item.Add(new ColorItem() { Text = colorNames[i], Color = ConvertColor(uintColors[i]) });
};
listPicker.ItemsSource = item; //Fill ItemSource with all colors
}
private Color ConvertColor(uint p)
{
byte A = (byte)((p & 0xFF000000) >> 24);
byte R = (byte)((p & 0x00FF0000) >> 16);
byte G = (byte)((p & 0x0000FF00) >> 8);
byte B = (byte)((p & 0x000000FF) >> 0);
return Color.FromArgb(A, R, G, B); ;
}
This is my ColorItem Class:
class ColorItem
{
public string Text { get; set; }
public Color Color { get; set; }
}
Like this:
And this:

you left out the xaml that actually builds the coloured squares. see link
<phone:PhoneApplicationPage
x:Class="CustomColorsPicker.ColorPickerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="False"
xmlns:converters="clr-namespace:CustomColorsPicker.Converters"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
toolkit:TiltEffect.IsTiltEnabled="True">
<phone:PhoneApplicationPage.Resources>
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox Name="listBox" SelectionChanged="lstColor_SelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="item" Orientation="Horizontal" Margin="12, 6 0, 6">
<Rectangle Fill="{Binding Color, Converter={StaticResource ColorToBrushConverter}}"
Width="100" Height="100" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
</phone:PhoneApplicationPage>

Related

ProgressRing never shows

I have created a page, in which I have placed inside the Grid the above:
<ProgressRing x:Name="Ring" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="True"/>
But when I do Ring.IsActive = true; in my code nothing happens! Possibly I am missing something very simple here, but I can't find out what it is.
This is my xaml:
<Page
x:Class="Diakopes_v2._0.AddExpense"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Diakopes_v2._0"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Background="#FF0277BD">
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Icon="Accept" Label="Accept" Click="Accept_Click"/>
<AppBarButton Icon="Cancel" Label="Cancel" Click="Cancel_Click"/>
</CommandBar>
</Page.BottomAppBar>
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF0277BD" Offset="0"/>
<GradientStop Color="#FFE1F5FE" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TextBlock Text="New Expense" TextAlignment="Center" FontSize="46" FontFamily="/Assets/Fonts/BebasNeue Bold.ttf#Bebas Neue"></TextBlock>
<StackPanel HorizontalAlignment="Left" Height="564" Margin="0,76,0,0" VerticalAlignment="Top" Width="400">
<TextBox x:Name="Name" PlaceholderText="Name"></TextBox>
<TextBox x:Name="Price" InputScope="Number" PlaceholderText="Price"></TextBox>
</StackPanel>
<ProgressRing x:Name="Ring" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="True"/>
</Grid>
</Page>
and this is my .cs method were I want to use the ProgressRing:
private void Accept_Click(object sender, RoutedEventArgs e) {
Ring.IsActive = true;
Name.Text = Name.Text.Trim();
Price.Text = Price.Text.Trim();
DBHelper dbHelper = new DBHelper();
Price.Text = Price.Text.Replace(",", ".");
ExpensesTable NewExpense = new ExpensesTable(Place.Id, Name.Text, Convert.ToSingle(Price.Text));
dbHelper.InsertExpense(NewExpense);
Ring.IsActive = false;
Frame.Navigate(typeof(Expenses), Place.Name);
}
I just created sample with code that you provided with simple modifications:
Turn on:
private void Accept_Click(object sender, RoutedEventArgs e)
{
Ring.IsActive = true;
}
Turn off:
private void Cancel_Click(object sender, RoutedEventArgs e)
{
Ring.IsActive = false;
}
Look at the screenshot from emulator:
Also, to remove black rect, you should change Background property to Transparent
So, I guess your code works so fast that you haven't time to see how works ProgressRing.

How to Add Show and Hide Button with Image in Listbox item in Windows Phone 8

i have a listbox with some contact number in listbox now i want to add Show and Hide button to each of contact item in list box when user press Hide button contact will be Hide and when user press Show button contact will be show and vise versa how i can do this in WP8..
i am using following code please help me..
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Margin="0, 10, 0, 10">
<Border BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="{StaticResource PhoneAccentBrush}" Margin="5, 0, 0, 0">
<Image Source="{Binding ImageUrl, Converter={StaticResource kconverter}}" Width="48" Height="48" Stretch="Fill"/>
</Border>
<TextBlock x:Name="item_name" Text="{Binding Name, Mode=OneWay}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="10, 0, 0, 0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0, 10, 0, 10">
<Border BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="{StaticResource PhoneAccentBrush}" Margin="355, 0, 0, 0">
<Image Name="onimg" Visibility="Visible" Source="/Assets/Images/blue.button.png" Width="85" Height="20" Tap="Image_TapOn" Stretch="Fill"/>
</Border>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0, 10, 0, 10">
<Border BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="{StaticResource PhoneAccentBrush}" Margin="355, 0, 0, 0">
<Image Name="offimg" Visibility="Collapsed" Source="/Assets/Images/setting-h.png" Width="85" Height="48" Tap="Image_TapOff" Stretch="Fill"/>
</Border>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Hi Use this code Hope so it works for you.
Note : Bind only ObservableCollection to ListBox to Use INotifyPropertyChanged
XAML :
<Grid Grid.Row="1">
<ListBox x:Name="lstContact">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Border Background="#404040"
Height="45"
Width="60"
Tag="{Binding ContactId}"
Tap="_Collapsed">
<TextBlock Text="-"
FontSize="24"
VerticalAlignment="Center"
TextAlignment="Center"
Foreground="White" />
</Border>
<Border Name="BrCount"
Width="160"
Height="45"
BorderBrush="#404040"
BorderThickness="0"
Margin="10,0">
<TextBlock Name="LblCont"
Text="{Binding ContactName}"
FontSize="24"
VerticalAlignment="Center"
TextAlignment="Center"
Foreground="#404040"
Visibility="{Binding _Visibility}" />
</Border>
<Border Background="#404040"
Height="45"
Width="60"
Tag="{Binding ContactId}"
Tap="_Visible">
<TextBlock Text="+"
FontSize="24"
VerticalAlignment="Center"
TextAlignment="Center"
Foreground="White" />
</Border>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
C# :
private ObservableCollection<Contact> _contact = new ObservableCollection<Contact>();
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
_contact = new ObservableCollection<Contact>();
for (int i = 0; i < 10; i++)
{
_contact.Add(new Contact() { ContactId = i, ContactName = "Name " + i, _Visibility = Visibility.Visible });
}
lstContact.ItemsSource = _contact;
}
private void _Collapsed(object sender, System.Windows.Input.GestureEventArgs e)
{
Border bdr = (Border)sender;
_contact.Where(X => X.ContactId == Convert.ToInt32(bdr.Tag.ToString())).First()._Visibility = Visibility.Collapsed;
}
private void _Visible(object sender, System.Windows.Input.GestureEventArgs e)
{
Border bdr = (Border)sender;
_contact.Where(X => X.ContactId == Convert.ToInt32(bdr.Tag.ToString())).First()._Visibility = Visibility.Visible;
}
public class Contact : INotifyPropertyChanged
{
public int ContactId { get; set; }
public string ContactName { get; set; }
public Visibility _visibility;
public Visibility _Visibility
{
get { return _visibility; }
set { SetProperty(ref _visibility, value); }
}
protected void SetProperty<T>(ref T storage, T value, [System.Runtime.CompilerServices.CallerMemberName] String propertyName = null)
{
if (!object.Equals(storage, value))
{
storage = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
protected void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] String propertyName = null)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}

how to get the checkbox value from the LongListSelector in wp8

My Longlistselector DataTemplate
<DataTemplate x:Key="NotesListBoxItemTemplate">
<Grid HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<CheckBox
Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
x:Name="chkDelete"
Visibility="Visible" Tap="chkDelete_Tap" Margin="0,36,0,0" />
<TextBlock
Text="{Binding NoteName}"
FontSize="{StaticResource PhoneFontSizeLarge}"
FontFamily="Segoe WP"
Grid.Row="0" Grid.Column="1" Margin="12,24,0,0" />
</Grid>
</DataTemplate>
and my Longlist selector is
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer>
<phone:LongListSelector
x:Name="MainListBox"
ItemsSource="{Binding AllData}"
Margin="12, 0, 12, 0"
ItemTemplate="{StaticResource ListBoxItemTemplate}" />
</ScrollViewer>
</Grid>
How do I loop through the items and get the Checkbox checked state in each item? Previously I used ListBox and its worked correctly. And I am able to find out the checkbox value of the each item using below code
private T FindFirstElementInVisaulTree<T>(DependencyObject parentElement) where T:DependencyObject
ListBoxItem passed as a DependencyObject. The only problem with ListBox is scrolling. So trying for LongListSelector.
Please how do i loop through the items in LongListSelector.
Thank you
You can also Data Bind the state of the checkbox to your Model. Then you can just loop through the MainListBox.ItemsSource. If you do it this way you need to set the Binding Mode=Two Way or the collection will not change once someone taps the Checkbox. I would also recommend you use a Command to handle the Tap event on the Checkbox so you can handle in your ViewModel rather then Code behind. Here's my quick example modified from previous solutions I have posted:
// Namespaces used
using System.Collections.ObjectModel; // ObservableCollection<T>
using System.ComponentModel; // INotifyPropertyChanged
// sample_data class
public class sample_data : INotifyPropertyChanged
{
// simple constructor
public sample_data(string noteName, Boolean checkboxState)
{
this.NoteName = noteName;
this.CheckboxState = checkboxState;
}
// implement the INotify
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
// {Binding Properties}
Boolean checkbox_state;
public Boolean CheckboxState
{
get { return checkbox_state; }
set { checkbox_state = value; NotifyPropertyChanged("CheckboxState"); }
}
string note_name;
public string NoteName
{
get { return note_name; }
set { note_name = value; NotifyPropertyChanged("NoteName"); }
}
}
// create a sample set of data to show
private ObservableCollection<sample_data> CreateData()
{
ObservableCollection<sample_data> my_list = new ObservableCollection<sample_data>();
my_list.Add(new sample_data("one", false));
my_list.Add(new sample_data("two", true));
my_list.Add(new sample_data("three", false));
my_list.Add(new sample_data("four", true));
my_list.Add(new sample_data("five", false));
my_list.Add(new sample_data("six", true));
my_list.Add(new sample_data("seven", false));
my_list.Add(new sample_data("eight", true));
return my_list;
}
public MainPage()
{
InitializeComponent();
MainListBox.ItemsSource = CreateData(); // set the data bind
}
/// You can loop through the items like this, use any convention you want.
private void LoopThroughItems()
{
foreach (sample_data sd in MainListBox.ItemsSource)
{
Boolean is_check = sd.CheckboxState;
}
}
Your DataTemplate needs to change so it Databinds the checkbox with two-way binding.
<DataTemplate x:Key="NotesListBoxItemTemplate">
<Grid HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" IsChecked="{Binding CheckboxState, Mode=TwoWay}" Grid.Row="0" Grid.RowSpan="2" x:Name="chkDelete" Visibility="Visible" Margin="0,36,0,0" />
<TextBlock Text="{Binding NoteName}" FontSize="{StaticResource PhoneFontSizeLarge}" FontFamily="Segoe WP" Grid.Row="0" Grid.Column="1" Margin="12,24,0,0" />
</Grid>
</DataTemplate>

Playing videos from RSS feed in windows phone

I have parsed the RSS feed http://www.teluguone.com/videosongs/videoSongsXml.php?cat_id=6 and displayed in listbox.When i click on a particular song automatically it should be navigated and start playing.But when i click on a song it is navigating to other page but not playing.It was displaying "An error occured please try again".I am not understanding where the problem is.I have written the following code.No errors and warnings are rising.
please help me.i was trying on this from many days.
Maipage.Xaml:
<phone:PhoneApplicationPage
x:Class="videosongs.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:delay="clr-namespace:Delay;assembly=PhonePerformance"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
<!--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 x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="Teluguone" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Videosongs" 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">
<ListBox x:Name="songsList"
SelectionChanged="songsList_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="130">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image delay:LowProfileImageLoader.UriSource="{Binding songpic}"
Grid.Column="0"
Width="97"
Height="125"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="6"/>
<StackPanel Margin="10,15,0,0"
Grid.Column="1"
Height="60"
Orientation="Horizontal"
VerticalAlignment="Top">
<TextBlock Text="{Binding songname}"
FontSize="30" />
</StackPanel>
<StackPanel Margin="0,50,0,0"
Grid.Column="1"
VerticalAlignment="Center">
<TextBlock Grid.Column="1"
Text="{Binding songdescr}"
Style='{StaticResource PhoneTextSubtleStyle}'
/>
<TextBlock Grid.Column="1"
Text="{Binding songdate}"
Style='{StaticResource PhoneTextSubtleStyle}'
/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ProgressBar x:Name="progress" Foreground="White" />
</Grid>
</Grid>
Mainpage.xaml.cs:
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
// is there network connection available
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
{
MessageBox.Show("No network connection available!");
return;
}
// start loading XML-data
WebClient downloader = new WebClient();
Uri uri = new Uri("http://www.teluguone.com/videosongs/videoSongsXml.php?cat_id=6", UriKind.Absolute);
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(VideosongsDownloaded);
downloader.DownloadStringAsync(uri);
}
void VideosongsDownloaded(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (e.Result == null || e.Error != null)
{
MessageBox.Show("There was an error downloading the XML-file!");
}
else
{
// Deserialize if download succeeds
XDocument document = XDocument.Parse(e.Result);
XmlSerializer serializer = new XmlSerializer(typeof(Videosongs));
Videosongs videosongs = (Videosongs)serializer.Deserialize(document.CreateReader());
songsList.ItemsSource = videosongs.Collection;
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.InnerException.Message);
MessageBox.Show(ex.ToString());
}
}
// selection in SongsdetailsList is changed
private void songsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = sender as ListBox;
if (listBox != null && listBox.SelectedItem != null)
{
Songsdetails song = (Songsdetails)listBox.SelectedItem;
System.Diagnostics.Debug.WriteLine(song);
NavigationService.Navigate(new Uri("/Videopage.xaml?songsongcode=" + song.songcode , UriKind.Relative));
}
}
}
}
Songsdetails.cs:
public class Songsdetails
{
[XmlElement("songname")]
public string songname { get; set; }
[XmlElement("songpic")]
public string songpic { get; set; }
[XmlElement("songcode")]
public string songcode { get; set; }
[XmlElement("songdescr")]
public string songdescr { get; set; }
[XmlElement("songtitletags")]
public string songtitletags { get; set; }
[XmlElement("songmetatags")]
public string songmetatags { get; set; }
[XmlElement("songmetadesc")]
public string songmetadesc { get; set; }
[XmlElement("songdate")]
public string songdate { get; set; }
[XmlElement("songurl")]
public string songurl { get; set; }
Videosongs.cs:
[XmlRoot("videosongs")]
public class Videosongs
{
//[XmlElement("publisher")]
//public string publisher { get; set; }
//[XmlElement("publisherurl")]
//public string publisherUrl { get; set; }
[XmlElement("songsdetails")]
public ObservableCollection<Songsdetails> Collection { get; set; }
Videopage.Xaml:
<phone:PhoneApplicationPage
x:Class="videosongs.Videopage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:extended="clr-namespace:MyToolkit.Controls;assembly=MyToolkit.Extended"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Landscape"
shell:SystemTray.IsVisible="False">
<StackPanel VerticalAlignment="Top" Height="600" Margin="0,0,0,0">
<TextBlock x:Name="title" TextWrapping="Wrap" VerticalAlignment="Top" Height="40"></TextBlock>
<phone:WebBrowser x:Name="webBrowser" Height="411" IsScriptEnabled="True" Margin="10,0,78,0" />
</StackPanel>
Videopage.Xaml.cs:
namespace videosongs
{
public partial class Videopage : PhoneApplicationPage
{
// Constructor
public Videopage()
{
InitializeComponent();
}
// When page is navigated to set data context to selected item in list
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (!NetworkInterface.GetIsNetworkAvailable())
{
MessageBox.Show("An error has occurred! Please verify your internet connection.");
NavigationService.GoBack();
}
else
{
string video = "http://www.youtube.com/embed/+getsongcode()";
System.Diagnostics.Debug.WriteLine(video);
this.webBrowser.Navigate(new Uri(video));
}
}
}
Anybody please help.Any help would be appreciated.
Many Thanks in advance.

ListBox Binding in windows Phone

I want to bind the item source in the List that resides in Pivot Control.How can i bind the itemsouce either in xaml or code.This is my code
<controls:Pivot x:Name="Category_pivot" Foreground="Black" FontSize="22">
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="45"></TextBlock>
</DataTemplate>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate>
<ListBox x:Name="d" ItemsSource="{Binding Item}">
<ListBox.ItemTemplate>
<DataTemplate>
<Image x:Name="img" Source="{Binding ImageSource}" ></Image>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
</Grid>
I may have spent too much time on this, but it bothered me...
You used Foreground="Black" in your example, and this means that the header is black so in a OOB project it is black-on-black.
Here is my XAML:
<phone:Pivot x:Name="Category_pivot" FontSize="22">
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}" FontSize="45"></TextBlock>
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<phone:Pivot.ItemTemplate>
<DataTemplate>
<ListBox x:Name="d" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ImageSource}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</phone:Pivot.ItemTemplate>
</phone:Pivot>
And my C#:
public partial class MainPage : PhoneApplicationPage
{
public class Data
{
public string Title { get; set; }
public ObservableCollection<SubData> Items { get; set; }
}
public class SubData
{
public string ImageSource { get; set; }
}
// Constructor
public MainPage()
{
InitializeComponent();
ObservableCollection<Data> list = new ObservableCollection<Data>();
Data d = new Data() { Title = "my page 1" };
d.Items = new ObservableCollection<SubData>();
d.Items.Add(new SubData() { ImageSource = "1" });
d.Items.Add(new SubData() { ImageSource = "2" });
list.Add(d);
d = new Data() { Title = "my page 2" };
d.Items = new ObservableCollection<SubData>();
d.Items.Add(new SubData() { ImageSource = "A" });
d.Items.Add(new SubData() { ImageSource = "B" });
list.Add(d);
Category_pivot.ItemsSource = list;
}
}