How to use PivotViewer in Silverlight xaml? - silverlight

How to use PivotViewer in Silverlight xaml? I read http://msdn.microsoft.com/en-us/library/system.windows.controls.pivot.pivotviewer(v=vs.95).aspx and added a reference to the assembly.But I get an error
The name "PivotViewer" does not exist in the namespace "http://schemas.microsoft.com/client/2007".
This is my xaml:
<UserControl x:Class="SilverlightApplication2.MainPage"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock Text="Hello world"></TextBlock>
<PivotViewer/>
</Grid>
</UserControl>

Added a reference to the assembly System.Windows.Controls.Pivot then
<UserControl x:Class="SilverlightApplication2.MainPage"
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:pivot="clr-namespace:System.Windows.Controls.Pivot;assembly=System.Windows.Controls.Pivot"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock Text="Hello world"></TextBlock>
<pivot:PivotViewer x:Name="pViewer" />
</Grid>
</UserControl>

I have a series on my blog that walks thru using the PivotViewer. That should get you started. http://tonychampion.net/blog/index.php/series/pivotviewer-basics/

Related

Change background opacity on startup

I would like to change background opacity (make it darker) when programs starts
<Window x:Class="PCSX4.MainWindow"
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:local="clr-namespace:PCSX4"
mc:Ignorable="d"
Title="MainWindow" Height="900" Width="900"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Background="Transparent">
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="0,0,0,1" CornerRadius="0" />
</WindowChrome.WindowChrome>
<Grid>
<Border Background="lightBlue" />
<Image HorizontalAlignment="Center" Height="1002" VerticalAlignment="Center" Width="900" RenderTransformOrigin="-2.3,-0.484" Source="/background.png" Stretch="Fill"/>
</Grid>
</Window>
Haven't tried anything because I don't know how to solve this problem as I'm new to this.

WPF I can not get MouseMove event when the form AllowsTransparency=true

<Window x:Class="mtWPFScratchPad.DeskForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="mtWPFScratchPad" AllowsTransparency="True" WindowState="Maximized" Loaded="Window_Loaded" WindowStyle="None" Background="#00FFFFFF" Closing="Window_Closing" Topmost="True" MouseMove="Window_MouseMove">
<InkCanvas Name="inkCanv" Background="Transparent">
</InkCanvas>
When i set the window should be transparency.I can not get the mousemove Event.
How to do this?
If you set Both transparent it's not working You have to change ink canvas color or either change Allow transparency = false
<Window x:Class="Demo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" AllowsTransparency="True" WindowState="Normal Loaded="Window_Loaded_1" WindowStyle="None" Background="#00FFFFFF" Closing="Window_Closing_1" Topmost="True" MouseMove="Window_MouseMove_1" Height="350" Width="525" >
<Grid>
<InkCanvas Name="inkCanvas" Background="White">
</InkCanvas>
</Grid>
</Window>

How to add Context Menu in wpf in Modern Metro UI

I am doing one wpf app using Modern Metro UI,i want context menus on this app
as i tried
<Controls:MetroWindow x:Class="Something" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title=""
Width="326.478"
Height="5" ShowIconOnTitleBar="True" ShowTitleBar="True"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d" ResizeMode="CanMinimize" Loaded="MetroWindow_Loaded" >
<Controls:MetroWindow.Resources>
<ContextMenu x:Key="MyContextMenu">
<MenuItem Header="Send" />
</ContextMenu>
</Controls:MetroWindow.Resources>
<Grid>
</Grid>
</Controls:MetroWindow>
I am trying to add Context Menu to Wpf application which uses Modern Metro UI
A context menu should be declared within the actual element:
<Controls:MetroWindow x:Class="Something" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title=""
Width="326.478"
Height="5" ShowIconOnTitleBar="True" ShowTitleBar="True"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d" ResizeMode="CanMinimize" Loaded="MetroWindow_Loaded" >
<Grid>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>

Visual Studio 2012 XAML Designer - Cannot add more than one item

I'm new to VS 2012, and I have this issue every time I use the XAML Designer.
Every time I add an item (e.g. a RadioButton, and Image, a Label) to my window, it deletes the previous one.
As a result, I can have only one item in my window, I know it is absurd, what am I missing?
Here is the xaml of the window
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" xmlns:Toolkit="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="KinectSetupDev.MainWindow"
Title="MainWindow" Height="400" Width="600">
<Toolkit:KinectSensorChooserUI x:Name="SensorChooserUI" VerticalAlignment="Center" Height="40" Margin="277,2,275,328"/>
</Window>
Here is the xaml of the window after dragging an image on it (from the Toolbox)
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" xmlns:Toolkit="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="KinectSetupDev.MainWindow"
Title="MainWindow" Height="400" Width="600">
<Image HorizontalAlignment="Left" Height="86" Margin="77,188,0,0" VerticalAlignment="Top" Width="111"/>
</Window>
As made clear by #Hans, I was trying to add multiple content items into a Window, in the XAML designer. This is just not possible so i had to:
1) Add a Grid to the Window.
2) Add any item to the grid.
It works, here is a sample code:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" xmlns:Toolkit="clr-namespace:Microsoft.Kinect.Toolkit;assembly=Microsoft.Kinect.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="KinectSetupDev.MainWindow"
Title="MainWindow" Height="768" Width="1024" Loaded="Window_Loaded_1">
<Grid HorizontalAlignment="Left" Height="736" VerticalAlignment="Top" Width="1012" Margin="2,2,0,0">
<Image x:Name="Image01" HorizontalAlignment="Left" Height="240" Margin="136,27,0,0" VerticalAlignment="Top" Width="320"/>
<TextBlock x:Name="tbMessages" HorizontalAlignment="Left" Height="60" Margin="10,606,-664,-426" TextWrapping="Wrap" VerticalAlignment="Top" Width="974"/>
<WpfViewers:KinectColorViewer HorizontalAlignment="Left" Height="240" Margin="666,0,-666,0" VerticalAlignment="Top" Width="320"/>
</Grid>
</Window>

WPF how to include resource

So as I was reading how to use a MVVM design in my project looking into a sample-MVVM-concept project I found this:
<Window x:Class="MVVMDemo.UserRegistrationView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewmodel="clr-namespace:MVVMDemo"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<viewmodel:ViewModel x:Key="ViewModel"/>
</Window.Resources>
<Grid DataContext="{Binding Source={StaticResource ViewModel}}">
I create a new project add this:
xmlns:viewmodel="clr-namespace:MVVMDemo"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<viewmodel:ViewModel x:Key="ViewModel"/>
</Window.Resources>
and "DataContext="{Binding Source={StaticResource ViewModel}}"" to the Grid clause.
But I get strange errors. What is the problem? How do I fix it?

Resources