XAML 하위 속성 풀어서 지정하기

C#/WPF 2012. 6. 13. 15:07 Posted by 퓨어레드

속성값에 값을 주는것 풀어서 할수 있다.

태그를 엘리먼트명.속성명이다.

 

Content 가 없는 속성들은 태그를 바로 닫아준다.

 

<Polygon xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         Points="144 48, 200 222, 53 114, 235 114, 88 222"
         Stroke="Blue"
         StrokeThickness="5">
    <Polygon.Fill>
        <RadialGradientBrush>
            <GradientStop Offset="0" Color="Blue" />
            <GradientStop Offset="1" Color="Red" />
        </RadialGradientBrush>
    </Polygon.Fill>
</Polygon>

WPF에서 실행파일이 있는 경로

C#/WPF 2012. 4. 19. 14:17 Posted by 퓨어레드

종종 프로젝트를 하다보면 실행파일이 있는 경로에서 파일을 생성하고 불러올 경우가 생긴다.
절대경로를 넣으면 되지만 차후에 배포를 위해 상대경로를 지정하는게 좋다.

 

C#에서는

Application.StartupPath를 사용하면 됐지만

WPF에서는

 

AppDomain.CurrentDomain.BaseDirectory;

// 또는

string appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);




이렇게 사용하면 된다.

 

Content 에 URI 로 이미지 넣기

C#/WPF 2012. 4. 18. 12:36 Posted by 퓨어레드

Uri 와  BitmapImage 를 써서 Content 에 이미지 넣기..

 

Uri uri = new Uri ("http://purred.kr/images/center/main.gif");

BitmapImage bitmapImage = new BitmapImage (uri);

Image img = new Image ();
img.Source = bitmapImage;

Content = img;

출처 : http://golee07.tistory.com/339

 

Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
 textbox.Text = "크로스 쓰레드 해결!";
}));

'C# > WPF' 카테고리의 다른 글

XAML 하위 속성 풀어서 지정하기  (0) 2012.06.13
WPF에서 실행파일이 있는 경로  (0) 2012.04.19
Content 에 URI 로 이미지 넣기  (0) 2012.04.18
WPF 다국어 지원  (0) 2012.04.17

WPF 다국어 지원

C#/WPF 2012. 4. 17. 18:19 Posted by 퓨어레드