zoukankan      html  css  js  c++  java
  • 【windows phone】控件1

     1     <Grid x:Name="LayoutRoot" Background="Transparent">
     2         <Grid.RowDefinitions>
    3 <RowDefinition Height="Auto"/>
    4 <RowDefinition Height="*"/>
    5 </Grid.RowDefinitions>
    6
    7 <!--TitlePanel contains the name of the application and page title-->
    8 <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
    9 <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
    10 <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    11 </StackPanel>
    12
    13 <!--ContentPanel - place additional content here-->
    14 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    15 <Grid.RowDefinitions >
    16 <RowDefinition Height="70*"/>
    17 <RowDefinition Height="70*"/>
    18 <RowDefinition Height="70*"/>
    19 <RowDefinition Height="70*"/>
    20 <RowDefinition Height="70*"/>
    21 <RowDefinition Height="70*"/>
    22 <RowDefinition Height="70*"/>
    23 <RowDefinition Height="70*"/>
    24 </Grid.RowDefinitions>
    25
    26 <Grid.ColumnDefinitions>
    27 <ColumnDefinition Width="60*" />
    28 <ColumnDefinition Width="10" />
    29 <ColumnDefinition Width="120*" />
    30 </Grid.ColumnDefinitions>
    31
    32 <TextBlock Name="myTextBlock1" Text="enter"
    33 Grid.Column="0"
    34 Grid.Row="0"/>
    35
    36 <TextBox Name="myTextBox"
    37 Grid.Column="2"
    38 Grid.Row="0"/>
    39
    40 <TextBlock Name="myTextBlock2" Text="are you want to do this"
    41 Grid.Column="0"
    42 Grid.Row="1"/>
    43
    44 <CheckBox Name="myCheckBox"
    45 Grid.Column="2"
    46 Grid.Row="1"/>
    47
    48 <TextBlock Name="myTextBlock3" Text="RadioButton"
    49 Grid.Column="0"
    50 Grid.Row="2"/>
    51
    52 <RadioButton Name="myRadioButton1"
    53 GroupName="gn"
    54 Content="cm"
    55 Grid.Column="2"
    56 Grid.Row="2"/>
    57 <RadioButton Name="myRadioButton2"
    58 GroupName="gn"
    59 Content="ms"
    60 Grid.Column="2"
    61 Grid.Row="3"/>
    62 <RadioButton Name="myRadioButton3"
    63 GroupName="gn"
    64 Content="msa"
    65 Grid.Column="2"
    66 Grid.Row="4"/>
    67
    68 <ListBox Name="myListBox"
    69 Grid.Column="0"
    70 Grid.Row="5"
    71 Grid.RowSpan="2" SelectionMode="Multiple">
    72 <ListBoxItem Content="haha" IsEnabled="True" IsSelected="True" />
    73 <ListBoxItem Content="haha"/>
    74 <ListBoxItem Content="haha"/>
    75 <ListBoxItem Content="haha"/>
    76 <ListBoxItem Content="haha"/>
    77 </ListBox>
    78
    79
    80 <Button Name="myButton"
    81 Grid.Column="2"
    82 Content="OK"
    83 Grid.Row="7"
    84 Click="myButton_Click"/>
    85
    86 </Grid>
    87 </Grid>

    ---界面代码

     1 namespace SecondProject
    2 {
    3 public partial class MainPage : PhoneApplicationPage
    4 {
    5 // Constructor
    6 public MainPage()
    7 {
    8 InitializeComponent();
    9 }
    10
    11 private void myButton_Click(object sender, RoutedEventArgs e)
    12 {
    13 Agent at = new Agent();
    14 at.AgentName = myTextBox.Text;
    15 if (myCheckBox.IsChecked==true)
    16 {
    17 at.IsUndercover=true;
    18 }
    19 else
    20 {
    21 at.IsUndercover=false;
    22 }
    23 //bool bl=at.IsUndercover;
    24 //bool? bl=myCheckBox.IsChecked;
    25
    26 if (myRadioButton1.IsChecked == true)
    27 {
    28 at.Agency = myRadioButton1.Content.ToString();
    29 }
    30 else if (myRadioButton2.IsChecked == true)
    31 {
    32 at.Agency = myRadioButton2.Content.ToString();
    33 }
    34 else
    35 {
    36 at.Agency = myRadioButton3.Content.ToString();
    37 }
    38
    39 ListBoxItem lbi = (ListBoxItem)myListBox.SelectedItem; //获取ListBox中所选中的数据
    40 at.Proficiency = (string)lbi.Content;
    41
    42 at.RecordCreatedDateTime = DateTime.Now;
    43
    44 at.Save();
    45
    46 myTextBox.Text = "";
    47
    48 myCheckBox.IsChecked = false;
    49
    50 myRadioButton1.IsChecked = false;
    51 myRadioButton2.IsChecked = false;
    52 myRadioButton3.IsChecked = false;
    53
    54 myListBox.SelectedItem = null;
    55
    56 }
    57 }
    58 }

    ---后台代码

     1 namespace SecondProject
    2 {
    3 public class Agent
    4 {
    5 public string AgentName { get; set; }
    6 public string Agency { get; set; }
    7 public bool? IsUndercover { get; set; }
    8 public string Proficiency { get; set; }
    9 public DateTime RecordCreatedDateTime { get; set; }
    10
    11
    12 public void Save()
    13 {
    14 this.AgentName = "";
    15 this.Agency = "";
    16 this.IsUndercover = false;
    17 this.Proficiency = "";
    18 this.RecordCreatedDateTime = DateTime.Now;
    19 }
    20 }
    21
    22
    23 }

    Agent.cs代码

    实现界面效果:

    功能:点击“OK”按钮可以实现说有数据清空!




  • 相关阅读:
    list和set的区别
    day13
    11期
    接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承具体类(concrete class)? 抽象类中是否可以有静态的main方法?
    Object类?
    swith的用法和注意事项?
    Ioc和DI的区别?
    多态的好处?
    抽象和接口的区别?
    内部类,匿名内部类?
  • 原文地址:https://www.cnblogs.com/ngnetboy/p/2413134.html
Copyright © 2011-2022 走看看