<textbox.behaviors>和<button.behaviors>未找到附加属性行为</button.behaviors> </textbox.behaviors>

时间:2013-05-20 06:44:16

标签: silverlight windows-phone-7 xaml

TextBox.Behavior在此属性中无效,Button.Behaviors也无法正常工作。请帮忙,我想在同一页面上创建一个列表, 因为我正在研究WP7 App:ToDO列表;

<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)
    {

    }
   }
  }

0 个答案:

没有答案