Silverlight Toolkit 5 Themes does not work - themes

I've got the Problem, that Toolkits Themes just don't wanna apply.
I've installed Silverlight RC 5, Toolkit 5 and are running in Visual Studio 2010 with a Project in Silverlight 3(doesnt offered me Silverlight 4 or higher though).
Well, I read a thousands of Tutorials but I cannot see my mistake.
I am able to use those Controls of the Toolkit properly, but the Theme...just won't apply.
Here's the code:
<UserControl x:Class="Wissensmanagement.Controls.PCategory"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
xmlns:theming="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.Toolkit"
xmlns:dark="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.ExpressionDark"
mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="625">
<Grid x:Name="LayoutRoot">
<dark:ExpressionDarkTheme>
<StackPanel HorizontalAlignment="Left">
<Button Width="60" Height="30" x:Name="btnLoad" HorizontalAlignment="Left" Content="Test" />
<controlsToolkit:Expander Header="test"/>
</StackPanel>
</dark:ExpressionDarkTheme>
</Grid>
And here is, what I See:
http://imageshack.us/photo/my-images/207/94160286.png/
If there were any hints, I would be appreciated =/

Please Check this link http://www.c-sharpcorner.com/UploadFile/mamta_m/working-with-themes-in-silverlight-toolkit-C-Sharp-based/
It will provide you some help
public Page()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
Uri uri = new Uri(#"ThemeDemo;component/Microsoft.Windows.Controls.Theming.RainierOrange.xaml", UriKind.Relative);
ImplicitStyleManager.SetResourceDictionaryUri(LayoutRoot, uri);
ImplicitStyleManager.SetApplyMode(LayoutRoot, ImplicitStylesApplyMode.Auto);
ImplicitStyleManager.Apply(LayoutRoot);
}
I hope it helps

Related

How to implement tab view in windows phone 8

In my windows application, I want to implement tab view like android tab view.
For reference please see the below image.
How should I Implement that in Windows phone 7 or 8.
I'm looking forward for your reply.
Thanks in Advance.
By default, the Windows Phone 7 SDK doesn't have a TabControl. It is a quite useful component already available in Silverlight and although it doesn't quite follow the Metro style.
Using the TabControl on Windows Phone 7 gives you better idea. Here is good example using tab control in wp7
<ListBox x:Name="lstBoxRss" SelectionChanged="lstBoxRss_SelectionChanged_1">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,5">
<TextBlock x:Name="txtblkLink" Text="{Binding Title}" Foreground="Blue" TextDecorations="Underline" TextWrapping="Wrap" Tap="txtblkLink_Tap" />
<TextBlock Text="{Binding PubDate}" Foreground="Red"/>
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" Foreground="Black"/>
<Button x:Name="btnOne" Content="ButtonOne" Click="btnOne_Click_1"/>
<Button x:Name="btnTwo" Content="Button Two" Click="btnTwo_Click_1"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
//Code behind
private void lstBoxRss_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
//Listbox selection change
// do your work
if(lstBoxRss.SelectedIndex==-1)
return;
}
private void btnOne_Click_1(object sender, RoutedEventArgs e)
{
//First button click
//Do your work
}
private void btnTwo_Click_1(object sender, RoutedEventArgs e)
{
//button two click
//Do your work
}
There is no TabControl in the Windows Phone SDK 8. The closest equivalent is a Pivot control. You can put a row of clickable text or icons at the top of a Pivot and make it operate like a tab bar.
http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/1baf74fa-0ddd-4226-a02d-a7fc9f80374d
Pivot control instead of a TabControl for the WindowsPhone. the Pivot control follows the design guidelines for the phone and looks and feels much better.
For Windows phone 7 visit this Link:
http://developer.nokia.com/community/wiki/Tab_Control_in_Qt_and_Windows_Phone

Can we play 2 videos simultaneously in windows phone 7 application

Can we play 2 videos simultaneously in windows phone 7 application.
I am using 2 media elements in 1 xaml page. But only one of the videos is getting displayed. How can I play videos. Please suggest some pointers.
You Can use only one MediaElement on a page. please refer MediaElement Design Guidelines First.
The reason you are seeing on video is because when we use MediaElement, all other playing audio video are stops.
The answer how can you play two videos using MediaElement or another option is CompositionTarget.Rendering Event.
CompositionTarget.Rendering actually renders a frame.
For details visit here.
Code in XAML
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<MediaElement Name="ME1" Source="/Images/oceansclip1.mp4" Stretch="Fill" AutoPlay="False" VerticalAlignment="Top" Height="250"/>
<MediaElement Name="ME2" Source="/Images/oceansclip2.mp4" Stretch="Fill" AutoPlay="False" VerticalAlignment="Top" Margin="0,10" Height="250"/>
<Button Content="Play" Click="Button_Click_1"/>
</StackPanel>
</Grid>
Code behind XAML
private void Button_Click_1(object sender, RoutedEventArgs e)
{
CompositionTarget.Rendering += CompositionTarget_Rendering1;
}
private void CompositionTarget_Rendering1(object sender, EventArgs e)
{
mediaElement1.Play();
mediaElement2.Play();
}
But CompositionTarget.Rendering do not guarantee time between the calls, so you may get frames running faster or slower.

Arbitrary Drag and Drop for WP7

I'm trying to find a method of displaying a text block or that will allow me to arbitrarily drag and drop drop that control around the screen.
I've scoured google and here, but every drag and drop related question I find is around exchanging data, not just position.
Is anyone aware of something ready to go, or can you point me in the direction I should be looking?
You can do this by using behaviors:
<TextBlock Text="Hello!">
<i:Interaction.Behaviors>
<el:MouseDragElementBehavior ConstrainToParentBounds="True"/>
</i:Interaction.Behaviors>
</TextBlock>
You need to add a reference to Microsoft.Expression.Interactions in your solution, and the following namespace at the top of your XAML file:
xmlns:el="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
The xaml:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Height="30" Margin="125,132,0,0"
Name="textBlock1" Text="TextBlock"
Width="83" MouseMove="textBlock1_MouseMove" />
</Grid>
and the code behind:
private void textBlock1_MouseMove(object sender, MouseEventArgs e)
{
TextBlock realSender = (TextBlock)sender;
var theParent = (Grid)realSender.Parent;
var position = e.GetPosition(theParent);
realSender.Margin = new Thickness(
position.X - realSender.Width / 2,
position.Y - realSender.Height / 2, 0, 0);
}
The toolkit sample used to include an example of doing this.
Not sure if it's still in there though as it was based on the gesture support which has since been deprecated. If it's gone check the August 2011 version.

Burn-in test for WP7

I'm experiencing very strange issues while developing a WP7 app that happen usually after 30m or 1h, despite the code is really simple, almost equal to examples. The emulator does not have any problem.
app crashes with no exception being thrown
unhandled exception: {"0xffffffff"} (Yes, message is "0xffffffff". And Stacktrace is null)
once i got an exception thrown while getting DateTimeOffset.Now property (!)
UI Thread frozen, couldn't terminate app, had to power cycle the device
So at this point i think that either WP7 is really unstable or my device hardware is faulty.
Does a burn-in test exists for WP7? Like Memtest86, Prime and other utilities for the desktop?
Edit: here is the code that is causing problems:
public partial class MainPage : PhoneApplicationPage
{
private Accelerometer _accelerometer;
private GeoCoordinateWatcher _gps;
public MainPage()
{
InitializeComponent();
_accelerometer = new Accelerometer();
_accelerometer.ReadingChanged += new EventHandler<AccelerometerReadingEventArgs>(_accelerometer_ReadingChanged);
_accelerometer.Start();
_gps = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
_gps.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(_gps_PositionChanged);
_gps.Start();
}
void _gps_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Dispatcher.BeginInvoke(() =>
{
TBLocation.Text = e.Position.Location.ToString();
});
}
void _accelerometer_ReadingChanged(object sender, AccelerometerReadingEventArgs e)
{
Dispatcher.BeginInvoke(() =>
{
TBAccelX.Text = string.Format("X: {0:F2} g", e.X);
TBAccelY.Text = string.Format("Y: {0:F2} g", e.Y);
});
}
}
<phone:PhoneApplicationPage
x:Class="AccelerometerTest2.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"
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">
<StackPanel>
<TextBlock Name="TBAccelX"/>
<TextBlock Name="TBAccelY"/>
<TextBlock Name="TBLocation"/>
</StackPanel>
</phone:PhoneApplicationPage>
EDIT: As i suspected the phone was faulty. The app had run properly on another device for 5 hours.
I would suspect a memory (or resource) leak.
What does the app do?
Does the error happen while using the app or if you just leave it?
Is the app doing anything on a timer?
Have you tried monitoring memory usage over the lifetime of the app?
As there are fewer other apps and things going on in the background with the emulator, the need for the system to reclaim resources from you app is likley to be much less. It is therefore possible that such issues may not also be seen on the emulator.
If you get the latest (beta) version of the [mango] developer tools you'll be able to run your code through the new, built in profiler so you can see what is happening over time.

MVVM Light - how to fire command from code behind

I need to fire command from WP7 applicationbar. Unfortunately it is not possible, but Laurent published interesting workaround:
private void ApplicationBarMenuItemClick(object sender, System.EventArgs e)
{
var vm = DataContext as MainViewModel;
if (vm != null)
vm.MyCommand.Execute(null);
}
Unfortunately my code behind does not see MainViewModel class or actually any ViewModel class at all! Data binding works well so ViewModel is working fine. What am I doing wrong?
Put a breakpoint on that line of code and check what the value of DataContext is when the breakpoint is hit. If it's null you've probably forgotten to set the data context in your view.
If the DataContext isn't null, make sure it's of type MainViewModel or else the line calling vm.MyCommand.Execute(null) won't ever be called.
Based on the code you pasted, your view should look something like this.
<phone:PhoneApplicationPage x:Class="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"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
shell:SystemTray.IsVisible="True"
DataContext="{Binding Path=Main, Source={StaticResource Locator}}"
>
<Grid x:Name="LayoutRoot" Background="Transparent">
<!-- the rest has been ommitted for simplicity -->
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="appBarMenuItem1" Click="ApplicationBarMenuItemClick" Text="Menu Item 1" />
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>
This assumes your ViewModelLocator has the property Main of type MainViewModel.

Resources