Siverlight에 있는 InvokeCommandAction은 이벤트의 파라메터를 CommandParameter로 전달해 주지 않는다.
어제 찾아보다가 발견한 것으로 이런 문제를 깔끔하게 해결해주는 포스트이다.

InvokeDelegateCommandAction이란 Behavior는 EventArgs를 CommandParameter로 전달해주는 매우 유용한 Behavior이다.

Silverlight Commands Hacks: Passing EventArgs as CommandParameter to DelegateCommand triggered by EventTrigger

http://weblogs.asp.net/alexeyzakharov/silverlight-commands-hacks-passing-eventargs-as-commandparameter-to-delegatecommand-triggered-by-eventtrigger

'Silverlight > ETC' 카테고리의 다른 글

Passing EventArgs as CommandParameter to DelegateCommand triggered by EventTrigger  (0) 2014.10.24
Rx Links & Querys  (0) 2012.06.26
Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

Reactive Extensions for .NET (Rx) - Forums
http://social.msdn.microsoft.com/Forums/pl-pl/rx/threads

 

Introducing Pushqa-Queryable Push Messages over OData
http://blog.petegoo.com/index.php/tag/signalr/

 

Home > C#, Programming, Rx, WPF > Building an Auto Complete control with Reactive Extensions (Rx)
http://blog.petegoo.com/index.php/2011/11/22/building-an-auto-complete-control-with-reactive-extensions-rx/

Rx: Curing Your Asynchronous Programming Blues
http://www.slideshare.net/jibyjohnc/rx-curing-your-asynchronous-programming-blues-qcon-london

 

Rx Workshop

http://www.slideshare.net/panesofglass/rx-workshop

 

Reactive Extensions v2.0 Release Candidate available now!

http://blogs.msdn.com/b/rxteam/archive/2012/06/20/reactive-extensions-v2-0-release-candidate-available-now.aspx

 

관찰자 디자인 패턴(Observer Design Pattern)

http://msdn.microsoft.com/ko-kr/library/ee850490.aspx

 

1) windows  Form    Rx mouse event operation.....

var up = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseUp")
         select evt.EventArgs.Location;

var move = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove")
         select evt.EventArgs.Location;


var down = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseDown")
       select evt.EventArgs.Location;

up.Subscribe(x => heleleText.Text=x.X.ToString());
down.Subscribe(x => heveleText.Text = x.Y.ToString());
move.Subscribe(x => hevoleText.Text = x.Y.ToString()+":"+x.Y.ToString());

2) WPF(XAML) mouse event operation..........

  [XAML]
  <Grid>
        <StackPanel>
            <TextBlock x:Name="heleleText" Text="helele and hevele"/>
            <TextBox x:Name="heveleText"/>

            <StackPanel Orientation="Horizontal">
                <ListBox x:Name="heleleList"/>
                <ListBox x:Name="heveleList"/>
            </StackPanel>

        </StackPanel>
    </Grid>

   [CS]
    var move = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove")
               select evt.EventArgs.GetPosition(this);
   
    var up = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseUp")
             select evt.EventArgs.GetPosition(this);
   
    var down = from evt in Observable.FromEventPattern<MouseEventArgs>(this, "MouseDown")
               select evt.EventArgs.GetPosition(this);
   
    var q = from start in down
            from pos in move.StartWith(start).TakeUntil(up)
            select pos;

    // q.ObserveOnDispatcher().Subscribe(s => this.Title = s.ToString());
   
    q.Subscribe(s => this.Title = s.ToString());
   
    var helele = Observable.Interval(TimeSpan.FromSeconds(1)).StartWith(-1);
   
    helele.ObserveOnDispatcher()
               .Subscribe(s => this.Title = s.ToString());
    // helele.Subscribe(s => this.Title = s.ToString());

    var changed = Observable.FromEventPattern<TextChangedEventArgs>(heveleText, "TextChanged");
   
    var input = (from e2 in changed
                 let text = ((TextBox)e2.Sender).Text
                 where text.Length >= 3
                 select text)
                .DistinctUntilChanged()
                .Throttle(TimeSpan.FromSeconds(1));
   
    input.ObserveOnDispatcher().Subscribe(
      x =>
      {
          heleleList.Items.Add(x);
      }
    );

    var input2 = Observable.FromEventPattern(heveleText, "TextChanged")
                          .Select(evt => ((TextBox)evt.Sender).Text)
                          .Timestamp()
                          .Do((Timestamped<string> evt) => heveleList.Items.Add(evt))
                          .Select(evt => evt.Value)
                          .Where(evt => evt.Length > 4)
                          .Do(evt => heveleList.Items.Add( evt) );
   
    input2.ObserveOnDispatcher().Subscribe(_ => { });


3) App(WinRT)  mouse event operation..........<PointerEventArgs>(this, "PointerMoved")

    <Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
        <StackPanel>
            <TextBlock x:Name="heleleText" Text="helele and hevele"/>
            <TextBox x:Name="heveleText"/>
            <TextBox x:Name="hevoleText"/>
            <StackPanel Orientation="Horizontal">
                <ListBox x:Name="heleleList"/>
                <ListBox x:Name="heveleList"/>
            </StackPanel>
        </StackPanel>
    </Grid>


  protected override void OnNavigatedTo(NavigationEventArgs e)
        {
                   
            var move = from evt in Observable.FromEventPattern<PointerEventArgs>(this, "PointerMoved")
                       select evt.EventArgs.GetCurrentPoint(this);

            var up = from evt in Observable.FromEventPattern<PointerEventArgs>(this, "PointerReleased")
                     select evt.EventArgs.GetCurrentPoint(this);

            var down = from evt in Observable.FromEventPattern<PointerEventArgs>(this, "PointerPressed")
                       select evt.EventArgs.GetCurrentPoint(this);

            var q = from start in down
                    from pos in move.StartWith(start).TakeUntil(up)
                    select pos;

            q.Subscribe(s => heleleText.Text = s.Position.ToString()); //위와 동일, 잘됨

            var helele = Observable.Interval(TimeSpan.FromSeconds(1)).StartWith(-1);

            helele.ObserveOnDispatcher()
                       .Subscribe(s => heveleText.Text = s.ToString());
            //helele.Subscribe(s => heveleText.Text = s.ToString()); //Thread Error

            var changed = Observable.FromEventPattern<TextChangedEventArgs>(hevoleText, "TextChanged");

            var input = (from e2 in changed
                         let text = ((TextBox)e2.Sender).Text
                         where text.Length >= 3
                         select text)
                                .DistinctUntilChanged()
                                .Throttle(TimeSpan.FromSeconds(1));

            input.ObserveOnDispatcher().Subscribe(x =>
            {
                heleleList.Items.Add(x);
            }
            );

            var input2 = Observable.FromEventPattern(hevoleText, "TextChanged")
                                  .Select(evt => ((TextBox)evt.Sender).Text)
                                  .Timestamp()
                                  .Do((Timestamped<string> evt) => heveleList.Items.Add(evt))
                                  .Select(evt => evt.Value)
                                  .Where(evt => evt.Length > 4)
                                  .Do(evt => heveleList.Items.Add(evt));

            input2.ObserveOnDispatcher().Subscribe(_ => { });
        }

 

 

'Silverlight > ETC' 카테고리의 다른 글

Passing EventArgs as CommandParameter to DelegateCommand triggered by EventTrigger  (0) 2014.10.24
Rx Links & Querys  (0) 2012.06.26
Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

Prism 4.0 Tips

Silverlight/ETC 2012.06.13 16:33

01. MVVM에서 DelegateCommand를 사용한 버튼의 사용가능 상태를 그리드뷰에 아이템 선택이 될때마다 확인하기

 

View

 

<Grid>
 <Grid.RowDefinitions>
  <RowDefinition Height="0.145*"/>
  <RowDefinition Height="0.855*"/>
 </Grid.RowDefinitions>


 <!--버튼들-->
 <StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Right" d:LayoutOverrides="HorizontalAlignment">
        <telerik:RadButton Content="취소" Command="{Binding CancelCommand}" Margin="5,0,0,0"/>
        <telerik:RadButton Content="삭제" Command="{Binding DeleteCommand}" Margin="5,0,0,0" />
        <telerik:RadButton Content="복구" Command="{Binding RecoverCommand}" Margin="5,0,0,0" />
 </StackPanel>
 
 <!--그리드뷰-->
 <telerik:RadGridView x:Name="rgvTask"
  AutoGenerateColumns="False"  RowIndicatorVisibility="Collapsed" ShowGroupPanel="False"
  ItemsSource="{Binding Tasks}"  IsReadOnly="True" Grid.Row="1" SelectionMode="Multiple" >
  <i:Interaction.Triggers>
   <i:EventTrigger EventName="SelectionChanged">
    <i:InvokeCommandAction Command="{Binding SelectionChangedTaskCommand}" CommandParameter="{Binding SelectedItems, ElementName=rgvTask}"/>
   </i:EventTrigger>
  </i:Interaction.Triggers>

  <telerik:RadGridView.Columns>
     <telerik:GridViewSelectColumn />
   <telerik:GridViewDataColumn Header="행번호" DataMemberBinding="{Binding No}" />
   <telerik:GridViewDataColumn Header="생성일시" DataMemberBinding="{Binding CreatedOn}" />
   <telerik:GridViewDataColumn Header="종료일시" DataMemberBinding="{Binding EndedTime}" />
   <telerik:GridViewDataColumn Header="설명" DataMemberBinding="{Binding Description}" />
  </telerik:RadGridView.Columns>
 </telerik:RadGridView>
</Grid>


ViewModel

 

//Prism MEF Container 프로젝트
//RaisePropertyChanged는 프리즘에서 제공

private ICommand cancelCommand;
/// <summary>
/// 취소 커맨드
/// </summary>
public ICommand CancelCommand
{
    get
    {
        if (cancelCommand == null)
        {
            cancelCommand = new DelegateCommand(
                () =>
                {
                  //취소 작업
                },
                () => HasSelectedTask);
        }
        return cancelCommand;
    }
}

private ICommand deleteCommand;
/// <summary>
/// 삭제 커맨드
/// </summary>
public ICommand DeleteCommand
{
    get
    {
        if (deleteCommand == null)
        {
            deleteCommand = new DelegateCommand(
                () =>
                {
                  //삭제작업
                },
                () => HasSelectedTask);
        }
        return deleteCommand;
    }
}

private ICommand recoverCommand;
/// <summary>
/// 복구 커맨드
/// </summary>
public ICommand RecoverCommand
{
    get
    {
        if (recoverCommand == null)
        {
            recoverCommand = new DelegateCommand(() => {//복구작업}, () => this.HasSelectedTask);
        }
        return recoverCommand;
    }
}

/// <summary>
/// 선택된 작업존재 여부를 확인 Linq 사용
/// </summary>
public bool HasSelectedTask
{
    get
    {
        var result = this.SelectedTasks.Any();
        return result;
    }
}

private ObservableCollection<Comm.Task> _tasks = new ObservableCollection<Comm.Task>();
/// <summary>
/// 작업 목록
/// </summary>
public ObservableCollection<Comm.Task> Tasks
{
    get { return _tasks; }
    set
    {
        _tasks = value;
        RaisePropertyChanged(() => this.Tasks);
    }
}

private ObservableCollection<Comm.Task> selectedTasks = new ObservableCollection<Comm.Task>();
/// <summary>
/// 선택된 작업들
/// </summary>
public ObservableCollection<Comm.Task> SelectedTasks
{
    get { return selectedTasks; }
    set
    {
        selectedTasks = value;
        RaisePropertyChanged(() => this.SelectedTasks);
    }
}

private ICommand selectionChangedTaskCommand;
/// <summary>
/// 선택 변경 커맨드
/// </summary>
public ICommand SelectionChangedTaskCommand
{
    get
    {
        if (selectionChangedTaskCommand == null)
        {
            selectionChangedTaskCommand = new DelegateCommand<object>(
                obj =>
                {
                    var items = obj as ObservableCollection<object>;
                    if(items == null)
                    {
                        items = new ObservableCollection<object>();
                    }
                    SelectedTasks = new ObservableCollection<Comm.Task>(items.Cast<Comm.Task>());
                    //커맨드의 상태변경 -> 버튼 활성화/비활성화
                    CancelCommand.RaiseCanExecuteChanged();
                    DeleteCommand.RaiseCanExecuteChanged();
                    RecoverCommand.RaiseCanExecuteChanged();
                });
        }
        return selectionChangedTaskCommand;
    }
}

'Silverlight > ETC' 카테고리의 다른 글

Passing EventArgs as CommandParameter to DelegateCommand triggered by EventTrigger  (0) 2014.10.24
Rx Links & Querys  (0) 2012.06.26
Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

1. 프린트 출력시 한글이 깨지는 현상

pdf파일로 변경하여 출력을 할 때 한글이 깨지는 현상은 font관련 문제로 맑은 고딕(Malgun Gothic)을 이용해서 디자인 작업을 해서 출력하면 한글이 깨지지 않음

 

'Silverlight > ETC' 카테고리의 다른 글

Rx Links & Querys  (0) 2012.06.26
Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
Twitter Client Lecture(강좌 목록) by Silverlight 5  (0) 2012.01.05
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

Rx, Linq Tips

Silverlight/ETC 2012.05.04 15:00

Rx 사용한 소스 정리 중 사용한 버전은 Rx SDK 1.1.11011

 

//기본 Linq 쿼리

var cards = from kkk in op.Entities
            where kkk.Cards != null && kkk.Cards.Any() == true
            let c = kkk.Cards
            from jjj in c
            select new UserCard(this.CommonDomainContext, kkk, jjj);

var cards2 = from kkk in op.Entities
             where kkk.Cards == null || kkk.Cards.Any() == false
             select new UserCard(this.CommonDomainContext, kkk, null);

var tcards = cards.Concat(cards2).OrderBy(p => p.User.Name);

 

//옵저버블로 만들고, 스레드 풀을 사용하고, 디스패처쓰고, 서브스크레블

tcards.ToObservable()
    .ObserveOn(Scheduler.ThreadPool)
    .ObserveOnDispatcher()
    .SubscribeOnDispatcher()
    .Subscribe(
    p =>
    {

        //next
        this.UserCards.Add(p);
    },
    c =>
    {

        //complete
    });

//레이지로 만들어서 사용해 보기도 했는데..원하는 방향이 아니였음

Lazy<ObservableCollection<UserCard>> lu = new Lazy<ObservableCollection<UserCard>>(
    () =>
    {
        ObservableCollection<UserCard> collection = new ObservableCollection<UserCard>(tcards);
        return collection;
    });

this.AllUserCards = lu.Value;

//스케줄러만 사용해서 스레드풀로 처리를 해볼려고 했는데..실행은 가능하나, 원하는 결론이 아님

Scheduler
    .Schedule(Scheduler.ThreadPool,
    sc =>
    {
        foreach (var user in op.Entities)
        {
            if (user.Cards != null && user.Cards.Any() == true)
            {
                var cards = from kkk in user.Cards
                            select new UserCard(this.CommonDomainContext, user, kkk);

                cards.ToList().ForEach(p =>
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        this.UserCards.Add(p);
                    });
                });
            }
        }
    });

//Linq subquery 사용 - Include

var orgMembers = this.ObjectContext.USERs_Proc(organizationId).ToList();
var results = from id in orgMembers
              join member in
                   (
                    from user in this.ObjectContext.Users.Include("Cards")
                    let cs = user.Cards
                    where user is Member
                          && (userName == "" || (user as Member).Name.Contains(userName))
                          && (cardId == "" || cs.Count(c => c.Id.Contains(cardId)) > 0)
                    select user
                   )
              on id equals member.Id
              select member;

//Rx 타이머

var timer = Observable.Interval(new TimeSpan(0, 0, 1))
                        .ObserveOnDispatcher();
timerDisp = timer.SubscribeOnDispatcher()
                .Subscribe(time =>
                {
                    if (this.Progress + 60 >= this.Total)
                    {
                        this.Progress = this.Total;
                        timerDisp.Dispose();
                    }
                    else
                        this.Progress += 60;
                });

 

//2개의 컬렉션을 가지고 새로운 컬렉션 생성하고, DataContext에 넣고, SubmitChange() 실행, Submitting 중 Cancel 가능

//모든 작업을 쓰레드풀에서 실행

Scheduler
      .Schedule(Scheduler.ThreadPool, () =>
  {
      var results = from kkk in cards
                    from jjj in permissionGroups
                    let d = (jjj is DoorPermissionGroup ? new CardDoorPermissionGroupRelation() { CardId = kkk.Id, GroupId = (jjj as DoorPermissionGroup).GroupId, LastState = 1 } : null)
                    let f = (jjj is FloorPermissionGroup ? new CardFloorPermissionGroupRelation() { CardId = kkk.Id, GroupId = (jjj as FloorPermissionGroup).GroupId, LastState = 1 } : null)
                    let p = (jjj is PartitionPermissionGroup ? new CardPartitionPermissionGroupRelation() { CardId = kkk.Id, GroupId = (jjj as PartitionPermissionGroup).GroupId, LastState = 1 } : null)
                    select new { door = d, floor = f, partition = p };

 

var doors = from kkk in
                (from kkkk in results
                 where kkkk.door != null
                 select kkkk.door)
            join jjj in this.Context.CardDoorPermissionGroupRelations
            on new { kkk.GroupId, kkk.CardId } equals new { jjj.GroupId, jjj.CardId } into outer
            from o in outer.DefaultIfEmpty()
            where o == null
            select kkk;
var floor = from kkk in
                (from kkkk in results
                 where kkkk.floor != null
                 select kkkk.floor)
            join jjj in this.Context.CardFloorPermissionGroupRelations
            on new { kkk.GroupId, kkk.CardId } equals new { jjj.GroupId, jjj.CardId } into outer
            from o in outer.DefaultIfEmpty()
            where o == null
            select kkk;
var partition = from kkk in
                    (from kkkk in results
                     where kkkk.partition != null
                     select kkkk.partition)
                join jjj in this.Context.CardPartitionPermissionGroupRelations
                on new { kkk.GroupId, kkk.CardId } equals new { jjj.GroupId, jjj.CardId } into outer
                from o in outer.DefaultIfEmpty()
                where o == null
                select kkk;

 

//이렇게 작업하면 스케줄 취소를 했을때 오류가 발생하지 않음

doors.Cast<CardDoorPermissionGroupRelation>().ToList().ForEach(
    p => this.Context.CardDoorPermissionGroupRelations.Add(p));
floor.Cast<CardFloorPermissionGroupRelation>().ToList().ForEach(
    p => this.Context.CardFloorPermissionGroupRelations.Add(p));
partition.Cast<CardPartitionPermissionGroupRelation>().ToList().ForEach(
    p => this.Context.CardPartitionPermissionGroupRelations.Add(p));

 

      submitOp = this.Context.SubmitChanges(
                  p =>
                  {
                      //공통
                      timerDisp.Dispose();

                      if (p.HasError == false)
                      {
                          if (p.IsCanceled == false)
                          {
                              //끝까지 완료
                              this.IsCompleted = true;
                              if (this.Completed != null)
                              {
                                  this.Completed(this, EventArgs.Empty);
                              }
                          }
                          else
                          {
                              //중간에 취소
                              this.IsCanceled = true;
                              this.Context.RejectChanges();
                          }
                      }
                      else
                      {
                          p.MarkErrorAsHandled();
                          this.Context.RejectChanges();
                      }
                  }, null);
  });
 
public void Cancel()
{
    if (submitOp.CanCancel == true)
    {
        submitOp.Cancel();

    }
}

 

 

///스케줄러와 Linq를 이용해서 대량 데이터 수정

addOpDisp = Scheduler
    .Schedule(Scheduler.ThreadPool, () =>
    {
        var results = from kkk in cards
                      let ds = (from door in kkk.CardDoorPermissionGroupRelations
                                select door.LastState = 1)
                      let fs = (from floor in kkk.CardFloorPermissionGroupRelations
                                select floor.LastState = 1)
                      let ps = (from part in kkk.CardPartitionPermissionGroupRelations
                                select part.LastState = 1)
                      let state = kkk.DownState = 1
                      let sum = ds.Count() + fs.Count() + ps.Count()
                      select sum;

 

        foreach (var r in results)
        {
        }
       
        submitOp = this.Context.SubmitChanges(
                        p =>
                        {
                            if (p.HasError == false)
                            {
                                if (p.IsCanceled == false)
                                {
                                    //끝까지 완료
                                    this.IsCompleted = true;
                                    if (this.Completed != null)
                                    {
                                        this.Completed(this, EventArgs.Empty);
                                    }
                                }
                                else
                                {
                                    //중간에 취소
                                    this.IsCanceled = true;
                                    this.Context.RejectChanges();
                                }
                            }
                            else
                            {
                                p.MarkErrorAsHandled();
                                this.Context.RejectChanges();
                            }

                            //공통
                            if (addOpDisp != null)
                                addOpDisp.Dispose();
                        }, null);

    });

'Silverlight > ETC' 카테고리의 다른 글

Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
Twitter Client Lecture(강좌 목록) by Silverlight 5  (0) 2012.01.05
[Arg_COMException] error solution: perhaps  (4) 2012.01.04
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

01. 풀스크린일 때 LostFocus가 되어도 전체화면을 유지 옵션
Application.Current.Host.Content.FullScreenOptions = System.Windows.Interop.FullScreenOptions.StaysFullScreenWhenUnfocused;

 

02. OOB 상태에서 업데이트 확인

if (App.Current.IsRunningOutOfBrowser)
{
    App.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(OnCheckAndDownloadUpdateCompleted);
    App.Current.CheckAndDownloadUpdateAsync();
}

void OnCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
    if (e.Error == null && e.UpdateAvailable)
    {
        MessageBox.Show("Application updated, please restart to apply changes.");
    }
}

 

03. Thread Cross Error 발생시            

Deployment.Current.Dispatcher.BeginInvoke(() => {});

 

04. DispatcherTimer

System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 000); // 100 Milliseconds
myDispatcherTimer.Tick += (ss, ee) =>
{
    if (this.Progress + 60 >= this.Total)
    {
        this.Progress = this.Total;
        myDispatcherTimer.Stop();
    }
    else
        this.Progress += 60;
};
myDispatcherTimer.Start();


 

05. 명시적 바인딩, Explicit
var binding = picker.GetBindingExpression(DateTimePicker.SelectedDateTimeProperty);
binding.UpdateSource();

 

 

06. Behavior, Trigger 만들기

Silverlight and WPF Behaviours and Triggers - Understanding, Exploring And Developing Interactivity using C#, Visual Studio and Blend

http://www.codeproject.com/Articles/57664/Silverlight-and-WPF-Behaviours-and-Triggers-Unders

 

 

07. 정규식 - 이메일

if (this.EmailId.Contains('@') == true)
{
    string emailPattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(emailPattern);

    System.Text.RegularExpressions.Match m = regex.Match(this.EmailId);

    if (m.Success == false)
    {
        //이메일 주소 오류
        return;
    }
}

 

8. 실버라이트5에서 async, await, Task 사용하기

Nuget으로 설치

Async Targeting Pack for Visual Studio 2012

http://www.microsoft.com/en-us/download/details.aspx?id=29576

 

'Silverlight > ETC' 카테고리의 다른 글

Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
Twitter Client Lecture(강좌 목록) by Silverlight 5  (0) 2012.01.05
[Arg_COMException] error solution: perhaps  (4) 2012.01.04
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

www.devpia.com에 올렸던 강좌입니다. 링크만 걸어 놓습니다.

Twitter Client 1

Twitter Client 2 (MVVM)

Twitter Client 3 (MEF)

Twitter Client 4 (RadGridView for RadControl)

Twitter Client 5 (Localization)

Twitter Client 6 (HierarchyChild)

Twitter Client 7 (PopupMenu)

Twitter Client 8 (Popup Window)

Twitter Client 9 (Popup Window 2)

Twitter Client 10 (MEF 2)


Daum RSS Reader

'Silverlight > ETC' 카테고리의 다른 글

Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
Twitter Client Lecture(강좌 목록) by Silverlight 5  (0) 2012.01.05
[Arg_COMException] error solution: perhaps  (4) 2012.01.04
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

실버라이트로 프로그램을 만들 때 가끔 나오는 오류인데..구글에서 찾아 봤을 때 거의 해결 방법을 찾을 수 없다.

[Arg_COMException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.60401.00&File=mscorlib.dll&Key=Arg_COMException

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
   at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)
   at System.Windows.Controls.TextBox..ctor()
   at MS.Internal.CoreTypes.GetCoreWrapper(UInt32 typeId)
   at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)
   at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)
   at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
   at MS.Internal.XcpImports.ConvertCValueForManagedWithType(Type propertyType, CValue& outVal, Int32 outDOType, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
   at MS.Internal.XcpImports.GetValue(IManagedPeerBase managedPeer, DependencyProperty property)
   at System.Windows.RoutedEventArgs.get_OriginalSource()
   at Telerik.Windows.Controls.RadWindow.OnLostFocus(RoutedEventArgs e)
   at System.Windows.Controls.Control.OnLostFocus(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)

문제점(the point at issue)
바인딩 데이터를 자동으로 처리하면서 이상한(?) 데이터를 넣을려고 하는 경우 발생할 확율 높음

해결책(a solution: perhaps)
바인딩 되는 데이터를 object형으로 Type을 바꾸어 주고 테스트를 해본다.
binding property change to object type.

내 경우에는 int? type 데이터를 20개 정도 바인딩으로 사용하고 있었는데, 지속적으로 위의 에러가 발생해서..엄청난 괴로움을 당하고 있었는데..object로 변형을 한 후에는 오류를 발생 시킬려고 일부러 이것 저것 눌러도 잘 발생을 하지 않는다.(그래도 100% 발생하지 않는 것은 아님)

'Silverlight > ETC' 카테고리의 다른 글

Prism 4.0 Tips  (0) 2012.06.13
Telerik Report Tips  (2) 2012.06.08
Rx, Linq Tips  (0) 2012.05.04
Silverlight Standard Tips  (0) 2012.04.27
Twitter Client Lecture(강좌 목록) by Silverlight 5  (0) 2012.01.05
[Arg_COMException] error solution: perhaps  (4) 2012.01.04
블로그 이미지

kaki104

/// Microsoft MVP - Windows Development 2014 ~ 2019 5ring /// twitter : @kaki104, facebook : https://www.facebook.com/kaki104 https://www.facebook.com/groups/w10app/

티스토리 툴바