Windows phone 7ベースコントロールの使用例

76120 ワード

基本的なコントロールはすべて中に入っています
windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子
windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子
windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子
windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子
windows phone7 基础控件使用的例子   windows phone7 基础控件使用的例子


View Code
<phone:PhoneApplicationPage 
x:Class="PhoneApp_Grid.TestPage"
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:controls
="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
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="800"
FontFamily
="{StaticResource PhoneFontFamilyNormal}"
FontSize
="{StaticResource PhoneFontSizeNormal}"
Foreground
="{StaticResource PhoneForegroundBrush}"
SupportedOrientations
="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible
="False"

>

<!--LayoutRoot -->
<Grid x:Name="LayoutRoot">
<controls:Panorama Title=" " >

<!--Panorama 1-->
<controls:PanoramaItem Header="Grid ">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="197" />
<ColumnDefinition Width="223" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="133" />
<RowDefinition Height="139" />
<RowDefinition Height="226" />
</Grid.RowDefinitions>
<TextBlock Text=" 0 1 " Grid.Row="0" Grid.Column="1"></TextBlock>
<Border Grid.Row="1" Grid.ColumnSpan="2"
Background
="Red"
>
<TextBlock Text=" 1 0-1 " TextAlignment="Center"></TextBlock>
</Border>
</Grid>
</controls:PanoramaItem>

<!--Panorama 2-->
<controls:PanoramaItem Header="PopUp">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="206" />
<ColumnDefinition Width="214" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="409" />
<RowDefinition Height="89" />
</Grid.RowDefinitions>
<Popup
x:Name="my_PopUp"
IsOpen
="False"
Margin
="96,118,124,97" Width="200" Grid.ColumnSpan="2">
<Border Background="Blue" Width="200" Height="200"
Opacity
="0.8" BorderThickness="0.5"
>
<TextBlock Text="PopUp" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
</Border>
</Popup>
<TextBlock Text=" " Margin="147,191,163,150" Height="68" Width="110" Grid.ColumnSpan="2"></TextBlock>
<Button Content=" PopUp" Grid.Row="1" Grid.Column="0" x:Name="ShowPopup" Click="ShowPopup_Click"></Button>
<Button Content=" PopUp" Grid.Row="1" Grid.Column="1" x:Name="HidePopup" Click="HidePopup_Click"></Button>
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="TextBox">
<Grid>
<TextBox Margin="7,135,15,291" Name="textBox1"
>
<TextBox.InputScope>
<InputScope>
<InputScopeName NameValue="Number"></InputScopeName>
</InputScope>
</TextBox.InputScope>
</TextBox>
<TextBox Margin="4,243,18,183" Name="textBox2"
>
<TextBox.InputScope>
<InputScope>
<InputScopeName NameValue="Url"></InputScopeName>
</InputScope>
</TextBox.InputScope>
</TextBox>
</Grid>

</controls:PanoramaItem>
<controls:PanoramaItem Header="PasswordBox">
<Grid>
<PasswordBox Height="72" HorizontalAlignment="Left" Margin="13,147,0,0" Name="passwordBox1" VerticalAlignment="Top" Width="393"
PasswordChar
="·"
/>
<PasswordBox Height="72" HorizontalAlignment="Left" Margin="15,260,0,0" Name="passwordBox2" VerticalAlignment="Top" Width="393"
PasswordChar
="@"
/>
</Grid>

</controls:PanoramaItem>
<controls:PanoramaItem Header="TextBlock">
<Grid>

<TextBlock TextWrapping="Wrap" Text=" ..........................." Height="57" Margin="108,152,75,289" Width="237"></TextBlock>
<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled"
Width
="217" Height="46" Margin="107,230,96,222">
<TextBlock Text=" .............. " Height="57" ></TextBlock>
</ScrollViewer>
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="Border">
<Grid>
<Border Height="152" Width="257"
BorderThickness
="0"
Background
="Bisque"
CornerRadius
="20,20,20,20"
>


</Border>
<!--CornerRadius -->
</Grid>

</controls:PanoramaItem>
<controls:PanoramaItem Header="ProgressBar">
<Grid>
<ProgressBar x:Name="Pro" Margin="76,82,84,348" Height="68" Width="260" Minimum="0" Maximum="100"></ProgressBar>
<ProgressBar Margin="81,244,79,186" IsIndeterminate="True" Height="68" Width="260"></ProgressBar>
<Button Content=" " x:Name="Pro_status" Height="72" HorizontalAlignment="Left" Margin="127,154,0,0" VerticalAlignment="Top" Width="160" Click="Pro_status_Click" />
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="Slider"
Loaded
="PanoramaItem_Loaded"
>
<Grid>
<Slider Height="84" HorizontalAlignment="Left" Margin="42,104,0,0" Name="slider1" VerticalAlignment="Top" Width="327" />
<Slider Height="241" HorizontalAlignment="Left" Margin="26,172,0,0" Name="slider2" VerticalAlignment="Top" Width="102"
Orientation
="Vertical"
Minimum
="1"
Maximum
="10"
ValueChanged
="slider2_ValueChanged"

/>
<TextBlock Height="30" HorizontalAlignment="Left" Margin="139,193,0,0" Text="1" VerticalAlignment="Top"
x:Name
="Slider_Num"
/>
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="ScrollViewer">
<Grid>
<ScrollViewer Height="33"
ScrollViewer.HorizontalScrollBarVisibility
="Auto"
ScrollViewer.VerticalScrollBarVisibility
="Disabled"
Margin
="56,233,56,0" Name="scrollViewer1" VerticalAlignment="Top" Width="308">
<TextBlock Text="ScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewerScrollViewer">

</TextBlock>
</ScrollViewer>
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="Button">
<Grid>
<Button Content=" " Height="76" Margin="114,23,94,399" Width="212"></Button>
<Button Content=" , "
Background
="Bisque"
Foreground
="Black"
Height
="103" Margin="36,134,35,261" Width="349">

</Button>
<Button
Content=" , "
Foreground
="Black"
Height
="100" Margin="36,134,35,264" Width="349">
<Button.Background>
<ImageBrush ImageSource="bg.jpg"></ImageBrush>
</Button.Background>
</Button>
</Grid>

</controls:PanoramaItem>
<controls:PanoramaItem Header="ToggleButton">
<Grid>

<ToggleButton Height="80"
Content
="Unchecked"
IsThreeState
="True"
Checked
="toggleButton1_Checked"
Unchecked
="toggleButton1_Unchecked"
Indeterminate
="toggleButton1_Indeterminate"
Margin
="69,115,91,0" Name="toggleButton1" VerticalAlignment="Top" />

<ToggleButton Height="80"
Content
="Unchecked"
Checked
="toggleButton2_Checked"
Unchecked
="toggleButton2_Unchecked"
Margin
="69,0,91,107" Name="toggleButton2" VerticalAlignment="Bottom" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="78,82,0,0" Name="textBlock1" Text="IsThreeState=True" VerticalAlignment="Top" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="70,278,0,0" Name="textBlock2" Text="IsThreeState=False" VerticalAlignment="Top" />
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="CheckBox">
<Grid>

<CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="88,84,0,0" Name="checkBox1" VerticalAlignment="Top" />
<CheckBox Content="CheckBox"
Background
="White"
Foreground
="DarkCyan"
Height
="83" HorizontalAlignment="Left" Margin="90,150,0,0" Name="checkBox2" VerticalAlignment="Top" Width="174">

<!--<CheckBox.RenderTransform>
<CompositeTransform SkewX="2" SkewY="2"></CompositeTransform>
</CheckBox.RenderTransform>
-->
</CheckBox>
</Grid>
</controls:PanoramaItem>
<controls:PanoramaItem Header="RadioButton">
<Grid>
<Grid Height="121" Margin="46,94,47,283" Width="327">
<RadioButton Content="1" Height="72" HorizontalAlignment="Left" Margin="26,17,0,0" Name="radioButton1" VerticalAlignment="Top" />
<RadioButton Content="2" Height="72" HorizontalAlignment="Left" Margin="116,18,0,0" Name="radioButton2" VerticalAlignment="Top" />
<RadioButton Content="3" Height="72" HorizontalAlignment="Left" Margin="214,19,0,0" Name="radioButton3" VerticalAlignment="Top" />
</Grid>

<Grid Margin="37,259,43,104" Height="135" Width="340">
<RadioButton Content="1" Height="72" HorizontalAlignment="Left" Margin="22,15,0,0" Name="radioButton4" VerticalAlignment="Top" />
<RadioButton Content="2" Height="72" HorizontalAlignment="Left" Margin="121,17,0,0" Name="radioButton5" VerticalAlignment="Top" />
</Grid>
<TextBlock Height="30" HorizontalAlignment="Left" Margin="36,223,0,0" Name="textBlock3" Text=" " VerticalAlignment="Top" />
<TextBlock Height="30" HorizontalAlignment="Left" Margin="45,47,0,0" Name="textBlock4" Text=" " VerticalAlignment="Top" />
</Grid>

</controls:PanoramaItem>
<controls:PanoramaItem Header="ListBox"
Loaded
="PanoramaItem_Loaded_1">
<Grid>
<ListBox

Height="472" HorizontalAlignment="Left" Margin="3,8,0,0" x:Name="listBox1" VerticalAlignment="Top" Width="410">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="30" Text="{Binding Str}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

</Grid>
</controls:PanoramaItem>
</controls:Panorama>

</Grid>

<!--Panorama ApplicationBar-->

</phone:PhoneApplicationPage>



View Code
  1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Net;
5 using System.Windows;
6 using System.Windows.Controls;
7 using System.Windows.Documents;
8 using System.Windows.Input;
9 using System.Windows.Media;
10 using System.Windows.Media.Animation;
11 using System.Windows.Shapes;
12 using Microsoft.Phone.Controls;
13 using System.Threading;
14 using System.Collections.ObjectModel;
15 namespace PhoneApp_Grid
16 {
17 public partial class TestPage : PhoneApplicationPage
18 {
19 public TestPage()
20 {
21 InitializeComponent();
22 }
23
24
25
26 private void HidePopup_Click(object sender, RoutedEventArgs e)
27 {
28 this.my_PopUp.IsOpen = false;
29 }
30
31 private void ShowPopup_Click(object sender, RoutedEventArgs e)
32 {
33 this.my_PopUp.IsOpen = true;
34 }
35
36 private void Pro_status_Click(object sender, RoutedEventArgs e)
37 {
38 this.Pro.Value = 0;
39 new Thread(new ThreadStart(StatusProgressBar)).Start();
40 }
41 #region
42 //ProgressBar
43 delegate void StatusProgressBardelegate();
44 private void StatusProgressBar() {
45 Thread.Sleep(500);
46 Dispatcher.BeginInvoke(new StatusProgressBardelegate(StatusProgressBar_UI));
47 }
48 private void StatusProgressBar_UI() {
49 if (this.Pro.Value < this.Pro.Maximum) {
50 this.Pro.Value++;
51 new Thread(new ThreadStart(StatusProgressBar)).Start();
52 }
53 }
54 #endregion
55
56 delegate void SliderValuedelegate(double D);
57 private void slider2_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
58 {
59 Dispatcher.BeginInvoke(new SliderValuedelegate(ShowSliderValue),e.NewValue);
60 }
61 private void ShowSliderValue(double D) {
62 this.Slider_Num.Text = D.ToString() ;
63 }
64
65 private void PanoramaItem_Loaded(object sender, RoutedEventArgs e)
66 {
67 this.Slider_Num.Text = "test1";
68 }
69
70 private void toggleButton1_Checked(object sender, RoutedEventArgs e)
71 {
72 this.toggleButton1.Content = "Checked";
73 }
74
75 private void toggleButton1_Unchecked(object sender, RoutedEventArgs e)
76 {
77 this.toggleButton1.Content = "Unchecked";
78 }
79
80 private void toggleButton1_Indeterminate(object sender, RoutedEventArgs e)
81 {
82 this.toggleButton1.Content = "Indeterminate";
83 }
84
85 private void toggleButton2_Checked(object sender, RoutedEventArgs e)
86 {
87 this.toggleButton2.Content = "Checked";
88 }
89
90 private void toggleButton2_Unchecked(object sender, RoutedEventArgs e)
91 {
92 this.toggleButton2.Content = "Unchecked";
93 }
94
95 public class DataList
96 {
97 public string Str { get; set; }
98 }
99 private void PanoramaItem_Loaded_1(object sender, RoutedEventArgs e)
100 {
101
102 ObservableCollection<DataList> List = new ObservableCollection<DataList>();
103 for (int Num = 1; Num <= 10; Num++)
104 {
105 List.Add(new DataList { Str = Num.ToString() });
106 }
107 this.listBox1.ItemsSource = List;
108 }
109
110
111
112
113 }
114 }