티스토리 뷰

Previous Platforms

Silverlight Standard Tips

kaki104 2012. 4. 27. 14:14
반응형

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

 

반응형
댓글