1

TextBox.Behavior此属性中不起作用,Button.Behaviors也无法正常工作。请帮助,我想在同一页面上创建一个列表,因为我正在开发 WP7 应用程序:待办事项列表;

<StackPanel Orientation="Horizontal">
                        <TextBox Name="textBoxNewListName"
                             MaxLength="100"
                             Height="70"
                            Text="{Binding NewListName,Mode=TwoWay}"
                             VerticalAlignment="Top"
                             Width="400"
                             FontSize="24"
                             InputScope="Text"
                             Background="#BFFFFFFF"
                             BorderBrush="#BFFFFFFF"
                             Foreground="Black"
                             Style="{StaticResource TaskDescriptionTextBoxStyle}">
                                <TextBox.Behaviors>
       <Infrastructure:TextBoxCommand CommandBinding="   {Binding GotFocusCommand}"/>
                                </TextBox.Behaviors>
                        </TextBox>
                        <Button Name="buttonNewList"
                             Width="62"
                             HorizontalAlignment="Right"
                             BorderThickness="0"
                             Padding="0">
                                <Image Source="Images\add.png"
                                     Height="35"
                                     Width="35"/>
                                <Button.Behaviors>
  <Infrastructure:ButtonCommand CommandBinding="{Binding AddNewListCommand}"/>
                                </Button.Behaviors>
                        </Button>
                    </StackPanel>



enter code here







using Microsoft.Phone.Controls;
using Microsoft.Practices.Prism.Commands;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Navigation;
using ToDo.Infrastructure;
using ToDo.ViewModels;

namespace ToDo
{
public partial class MainPage : PhoneApplicationPage
{
    public const string MASTERLISTFILENAME = "MasterList.dat";



    public MainPage()
    {
        this.InitializeComponent();
    }

    private void ApplicationBarMenuItem_About_Click(object sender, EventArgs e)
    {
        MainViewModel dataContext = base.DataContext as MainViewModel;
        if (dataContext != null)
        {
            dataContext.ShowAboutPageCommand.Execute();
        }
    }



    private void listBoxExistingLists_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        ListViewModel selectedItem = this.listBoxExistingLists.SelectedItem as ListViewModel;
        this.listBoxExistingLists.SelectedIndex = -1;
        if (selectedItem != null)
        {
            selectedItem.ShowListPivotPageCommand.Execute();
        }
    }

    private void MainPage_DestinationPageChanged(object sender, PageChangedEventArgs e)
    {
        base.NavigationService.Navigate(e.Destination);
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        if (base.DataContext == null)
        {
            base.DataContext = new MainViewModel();
  (base.DataContext as MainViewModel).DestinationPageChanged +=
     new MainViewModel.PageChangedEventHandler
            (this.MainPage_DestinationPageChanged);
            this.listBoxExistingLists.DataContext = base.DataContext;
        }
    }

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {

    }
   }
  }
4

0 回答 0