Surface2014. 4. 10. 11:32

일단 스토리보드는 타겟이 있어야 한다 대부분 디자이너나 블랜드에서 만들면 타겟을

 

Storyboard.TargetName="xDetailItem"

 

이런코드가 삽입된다

 

일단 xaml에서 TargetName을 다 제거한다.. 그리고 이 타겟을 Behind에서 추가해준다.

 

일단 아래와 같이 제거

 

 <Storyboard x:Key="CalculatorOpen">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

 

 

자 이제 code behind에서

 

  ScatterViewItem svi = new ScatterViewItem()
                {
                    Center = (e.Source as DragAndDropScatterViewItem).Center,
                    Content = CalUc,
                    Orientation = 0,
                    Width = 263,
                    Height = 311,
                    RenderTransformOrigin = new Point(0.5, 0.5),
                    CanScale = false,
                };
                TransformGroup transGroup = new TransformGroup();
                transGroup.Children.Add(new ScaleTransform());
                transGroup.Children.Add(new TranslateTransform());
                transGroup.Children.Add(new RotateTransform());
                transGroup.Children.Add(new SkewTransform());
                svi.RenderTransform = transGroup;
                xScatterView.Items.Add(svi);

 

이런식으로 오브젝트를  하나 만들었다.

xaml에 Transform을 이용하기 떄문에 오브젝트에서도 이렇게 만들어줘야 된다.

 

자 간단하게 타겟을 지정해보자.

 

   Storyboard sb = this.Resources["CalculatorOpen"] as Storyboard;

   sb.Begin(svi);

 

아... 간단하다. begin(오브젝트)만 붙이면 된다.

Posted by 동동(이재동)
Windows Phone 72011. 3. 31. 15:13
xaml 상단에 이렇게 datacontext를 연결하고
 
DataContext="{Binding BookViewModel, Source={StaticResource Locator}}"
 
<phone:PhoneApplicationPage
    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:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:HugeFlow.FortuneCoins.Controls"
    xmlns:uc="clr-namespace:HugeFlow.FortuneCoins.Controls"
    xmlns:wp="clr-namespace:HugeFlow.Phone.Controls;assembly=HugeFlow.Phone.Controls"
    xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:HugeFlow_CommandPattern_Interactivity="clr-namespace:HugeFlow.CommandPattern.Interactivity;assembly=HugeFlow.MVVM" 
    x:Class="HugeFlow.FortuneCoins.Views.BookView"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"    
    shell:SystemTray.IsVisible="False" DataContext="{Binding BookViewModel, Source={StaticResource Locator}}">
 
behind에서 datacontext를 연결한후
 
private LocationPermissionViewModel _viewModel;
 
     public LocationPermissionView()
     {
         InitializeComponent();
         _viewModel = this.DataContext as LocationPermissionViewModel;
     }
 
그리고 커맨드를 사용할 버튼 이벤트에 이렇게

private void NoButton_Click(object sender, RoutedEventArgs e)
      {
          _viewModel.NoButtonClickCommand.Execute(null);
      }
Posted by 동동(이재동)
Windows Phone 72011. 1. 5. 13:15
난 처음에 Image를 넣어야 하는줄 알았더니 BitMapImage를 넣어야 하는것이였다.
 
사용하는 부분은 이렇게 이고
ItemImageSource = new BitmapImage(new Uri("/HugeFlow.FortuneCoins;component/Images/item/Coins_9.png", UriKind.RelativeOrAbsolute));            
 
 
 private BitmapImage _ItemImageSource;
        /// <summary>
        /// TODO:아이템 이미지 변경
        /// </summary>
        public BitmapImage ItemImageSource
        {
            get
            {
                return _ItemImageSource;
            }
            set
            {
                _ItemImageSource = value;

                OnPropertyChanged("ItemImageSource");
            }
        }
 
xaml코드에는
<Image Source="{Binding ItemImageSource}"  Stretch="Fill"/>
 
바인딩해서 사용하였다.
 
Posted by 동동(이재동)
Windows Phone 72010. 10. 7. 17:09

private void CreateApplicationBar()
{
    ApplicationBar = new ApplicationBar();
    ApplicationBar.IsVisible = true;
    ApplicationBar.IsMenuEnabled = false;
 
    ApplicationBarIconButton apDoneButton = new ApplicationBarIconButton(new Uri("icons/appbar.check.rest.png", UriKind.Relative));
    apDoneButton.Text = "Done";
    apDoneButton.Click += new EventHandler(apDoneButton_Click);
 
    ApplicationBarIconButton apCancelButton = new ApplicationBarIconButton(new Uri("icons/appbar.cancel.rest.png", UriKind.Relative));
    apCancelButton.Text = "Cancel";
    apCancelButton.Click += new EventHandler(apCancelButton_Click);
 
    ApplicationBar.Buttons.Add(apDoneButton);
    ApplicationBar.Buttons.Add(apCancelButton);
 
}

 

시간이 없으므로 소스로 대신한다.

Posted by 동동(이재동)