textbox binding

refresh command
This commit is contained in:
2011-03-28 09:34:32 +03:00
parent a25a7fb3fd
commit a4c09735f0
12 changed files with 46 additions and 15 deletions
+5 -1
View File
@@ -6,12 +6,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel">
xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel"
xmlns:my="clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls"
xmlns:my1="clr-namespace:Microsoft.Silverlight.Testing.Client;assembly=Microsoft.Silverlight.Testing">
<!--Application Resources-->
<Application.Resources>
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
<my:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
<my1:InvertValueConverter x:Key="InvertValueConverter1" />
</Application.Resources>
<Application.ApplicationLifetimeObjects>
+4
View File
@@ -14,6 +14,7 @@ using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using MyFriendsAround.WP7.ViewModel;
using MyFriendsAround.WP7.Utils;
using GalaSoft.MvvmLight.Threading;
namespace MyFriendsAround.WP7
@@ -45,6 +46,7 @@ namespace MyFriendsAround.WP7
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
DispatcherHelper.Initialize();
LoadModel();
}
@@ -52,6 +54,7 @@ namespace MyFriendsAround.WP7
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
DispatcherHelper.Initialize();
LoadModel();
}
@@ -75,6 +78,7 @@ namespace MyFriendsAround.WP7
private void LoadModel()
{
//
MainViewModel mainModel = this.RetrieveFromIsolatedStorage<MainViewModel>();
if (mainModel != null)
{
@@ -63,6 +63,12 @@
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<ItemGroup>
<Reference Include="Coding4Fun.Phone.Controls, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Coding4Fun.Phone.Controls.Complete.1.2\lib\Coding4Fun.Phone.Controls.dll</HintPath>
</Reference>
<Reference Include="Coding4Fun.Phone.Controls.Toolkit">
<HintPath>..\packages\Coding4Fun.Phone.Controls.Complete.1.2\lib\Coding4Fun.Phone.Controls.Toolkit.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.WP7">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP7\GalaSoft.MvvmLight.WP7.dll</HintPath>
@@ -79,7 +85,7 @@
</Reference>
<Reference Include="Microsoft.Phone.Controls.Maps, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e" />
<Reference Include="Microsoft.Phone.Controls.Toolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b772ad94eb9ca604, processorArchitecture=MSIL">
<HintPath>..\packages\SilverlightToolkitWP.4.2011.2.1\lib\sl4\Microsoft.Phone.Controls.Toolkit.dll</HintPath>
<HintPath>..\packages\Coding4Fun.Phone.Controls.Complete.1.2\lib\Microsoft.Phone.Controls.Toolkit.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Silverlight.Testing">
<HintPath>..\Libs\SL3_UTF_May\Microsoft.Silverlight.Testing.dll</HintPath>
@@ -171,6 +177,7 @@
<Content Include="icons\appbar.questionmark.rest.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="icons\appbar.sync.rest.png" />
<Content Include="SplashScreenImage.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -56,11 +56,12 @@ namespace MyFriendsAround.WP7.ViewModel
/// </summary>
public MainViewModel()
{
MyName = "Guest";
//
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
InputBoxCommand = new RelayCommand(() => InputBox());
NavigateToAboutCommand = new RelayCommand(() => NavigateToAbout());
RefreshFriendsCommand = new RelayCommand(() => RefreshFriends());
if (IsInDesignMode)
{
@@ -69,12 +70,16 @@ namespace MyFriendsAround.WP7.ViewModel
else
{
// Code runs "for real"
IsBusy = true;
ServiceAgent.GetFriends(this.GetFriendsResult);
}
}
private void RefreshFriends()
{
IsBusy = true;
ServiceAgent.GetFriends(this.GetFriendsResult);
}
private void NavigateToAbout()
{
//
@@ -163,12 +168,8 @@ namespace MyFriendsAround.WP7.ViewModel
public ICommand PublishLocationCommand { get; set; }
public ICommand DisplayAboutCommand { get; set; }
public ICommand InputBoxCommand { get; set; }
public ICommand NavigateToAboutCommand
{
get;
private set;
}
public ICommand NavigateToAboutCommand { get; set; }
public ICommand RefreshFriendsCommand { get; set; }
/// <summary>
@@ -206,6 +207,11 @@ namespace MyFriendsAround.WP7.ViewModel
get { return "Publish"; }
}
public string AppBarTextRefresh
{
get { return "Refresh"; }
}
////public override void Cleanup()
////{
//// // Clean up if needed
+13 -2
View File
@@ -19,7 +19,8 @@
shell:SystemTray.IsVisible="True"
DataContext="{Binding Main, Source={StaticResource Locator}}"
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview">
xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview"
xmlns:binding="clr-namespace:Coding4Fun.Phone.Controls.Binding;assembly=Coding4Fun.Phone.Controls">
<!--LayoutRoot contains the root grid where all other page content is placed-->
@@ -37,6 +38,12 @@
</ControlTemplate>
</phone:PhoneApplicationPage.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<cmd:EventToCommand Command="{Binding RefreshFriendsCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid x:Name="LayoutRoot"
Background="Transparent">
<Grid.RowDefinitions>
@@ -80,7 +87,8 @@
Name="txtMyName"
Text="{Binding Path=MyName, Mode=TwoWay}"
VerticalAlignment="Bottom"
Width="468" />
Width="468"
binding:TextBoxBinding.UpdateSourceOnChange="True" />
<my:Map x:Name="map"
Height="468"
HorizontalAlignment="Left"
@@ -110,6 +118,9 @@
<Preview:BindableApplicationBar x:Name="AppBar"
BarOpacity="0.5">
<Preview:BindableApplicationBarIconButton Command="{Binding RefreshFriendsCommand}"
IconUri="/icons/appbar.sync.rest.png"
Text="{Binding AppBarTextRefresh}" IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
<Preview:BindableApplicationBarIconButton Command="{Binding PublishLocationCommand}"
IconUri="/icons/appbar.publish.png"
Text="{Binding AppBarTextPublish}" />
@@ -12,8 +12,6 @@ namespace MyFriendsAround.WP7
// Constructor
public MainPage()
{
DispatcherHelper.Initialize();
InitializeComponent();
Messenger.Default.Register<DialogMessage>(
Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

+1
View File
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SilverlightToolkitWP" version="4.2011.2.1" />
<package id="Coding4Fun.Phone.Controls.Complete" version="1.2" />
</packages>