'wpf'에 해당되는 글 51건

  1. 2025.03.17 터치 스크롤 뷰어 List
  2. 2025.01.07 listbox에서 터치스크롤시 화면 전체가 움직일떄
  3. 2023.06.09 [WPF] 체크박스 xName을 이용하여 반복작업 하지 않고 간결하게
  4. 2023.06.08 MEF란?
  5. 2023.06.07 [WPF] gRPC Client 빌드 안될때 대처법
  6. 2022.12.05 dynamic property 에서 Set을 할떄
  7. 2022.10.26 public (string name, int age) GetUser()
  8. 2022.08.31 PeriodicTimer
  9. 2021.11.18 2개의 LIST 비교 하는것
  10. 2021.08.24 싱글톤 쓰기
  11. 2021.05.06 Combox 에 Enum 바인딩
  12. 2020.04.28 WPF에서 기본적으로 제공해주는 BoolToVisConverter 컨버터
  13. 2020.03.06 WPF TabControl에서 SelectionChanged가 계속 호출되는 문제
  14. 2019.04.24 이벤트 중복 호출 되지 않게 하는법
  15. 2019.03.21 list depp copy , clone 하는 간단한 방법
  16. 2019.02.26 OpenCV, Face API를 이용해서 얼굴 검출하기 2번째
  17. 2019.02.25 Face API를 이용하여 얼굴 검색 및 비교해서 동일인 찾기
  18. 2019.02.14 listbox 스크롤 안될때 확인해야하는점
  19. 2019.01.22 리스트에 빈칸없이 꽉 차게 넣는 로직 알고리즘
  20. 2018.11.13 라디오 컨트롤 바인딩
  21. 2018.10.23 스크롤시 프로그램창 자체가 움직일때 해결
  22. 2018.08.31 WPF Title Icon 제거하기
  23. 2018.08.29 WPF 강제 소프트웨어 렌더링 설정
  24. 2018.08.07 ViewBox에서 폰트사이즈 고정하기
  25. 2018.05.02 WPF에서 GIF 돌리기 컨트롤 1
  26. 2018.03.07 Xaml에 Binding을 하지 않고 컨버터를 쓰고 싶을때
  27. 2017.10.19 wpf FlipView
  28. 2017.09.12 Listview , Button MouseOver, Selcted Color 제거
  29. 2017.09.06 Converter를 쓰지 않고 바인딩된 TextBlock에 글자를 추가하고 싶을때
  30. 2017.08.22 LIST의 UI에 즉각적으로 바인딩 업데이트를 하고 싶을때..
wpf2025. 3. 17. 16:49

ListView안의 List에서는 터치가 안먹는다. 이떄는 

<ListView ItemsSource="{Binding ElementName=xMainPage , Path=DataContext.AllMenuFlipData}">
    <ListView.Template>
        <ControlTemplate>
            <StackPanel IsItemsHost="True" />
        </ControlTemplate>
    </ListView.Template>

 

이런식으로 Template안의 Panel에서 IsItemHost 를 True로 바꿔주면 된다.

 

GPT에선

IsItemsHost 속성은 주로 **Panel**에서 사용되며, 이 속성이 **true**로 설정된 경우 해당 패널이 항목을 호스트하는 역할을 한다는 것을 의미합니다.

 

이렇게 할경우 list에서 스크롤할떄 전체로 스크롤 된다.

 

키오스크 개발할떄 필수인거 같다.!! 

 

Posted by 동동(이재동)
wpf2025. 1. 7. 11:35

listbox에 ManipulationBoundaryFeedback 이벤트를 설정하여

 

behind에서

e.Handled = true;

를 한다.

Posted by 동동(이재동)
wpf2023. 6. 9. 18:37

 private void MessageCheck_Checked(object sender, RoutedEventArgs e)
        {
            if (IsLoaded == false)
                return;

            var name = (sender as ToggleButton).Name;

            var ctl = xGroups.FindName(name) as ToggleButton;

            DataManager.LocalData.MessageSelect.GetType().GetProperty(name.Remove(0, 1)).SetValue(DataManager.LocalData.MessageSelect, ctl.IsChecked);

            DataManager.Instance.SaveData();
        }

        private void TelegramMessageSelectPage_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if ((e.NewValue) as bool? == false)
                return;

            foreach (var item in DataManager.LocalData.MessageSelect.GetType().GetProperties())
            {
                var ctl = xGroups.FindName($"x{item.Name}") as ToggleButton;

                if (ctl != null)
                    ctl.IsChecked = (bool)item.GetValue(DataManager.LocalData.MessageSelect);
            }
        }

 

 public class MessageSelectModel
    {
        public bool IsDeepSleep { get; set; }

        public bool IsStartEndMap { get; set; }

        public bool IsDriveEnd { get; set; }
    }

 

 

 

그냥 바인딩하는게 최고지만 피지 못할경우에는 

 xIsAutoAfterBlowBtn.IsChecked = DataManager.LocalData.IsAutoAfterBlow; <-이런식으로 노가다 작업하지말고

 

xName이랑 프로퍼티랑 이름을 같게해서 반복작업을 줄여보자

'wpf' 카테고리의 다른 글

터치 스크롤 뷰어 List  (0) 2025.03.17
listbox에서 터치스크롤시 화면 전체가 움직일떄  (0) 2025.01.07
MEF란?  (0) 2023.06.08
[WPF] gRPC Client 빌드 안될때 대처법  (0) 2023.06.07
dynamic property 에서 Set을 할떄  (0) 2022.12.05
Posted by 동동(이재동)
wpf2023. 6. 8. 14:50

https://blog.powerumc.kr/189

 

[MEF] 1. Managed Extensibility Framework 이란?

MEF (Managed Extensibility Framework) 란? Menaged Extension Framewkr(이하 MEF) 란? 가장 쉽게 얘기하자면, 어플리케이션과 컴포넌트의 재사용성을 높일 수 있는 프레임워크입니다. 기존의 어플리케이션은 하나

blog.powerumc.kr

 

여기에 잘정리 되어 있으니 보자..

 

Menaged Extension Framewkr(이하 MEF) 란? 가장 쉽게 얘기하자면, 어플리케이션과 컴포넌트의 재사용성을 높일 수 있는 프레임워크입니다. 기존의 어플리케이션은 하나의 목적을 하나의 어플리케이션으로 구현한 정적인(Statically) 어플리케이션이라면, MEF 는 보다 동적인(Dynamically) 어플리케이션을 구축할 수 있는 새로운 라이브러리를 제공합니다.

Posted by 동동(이재동)
wpf2023. 6. 7. 15:25

서버야 프로젝트 템플릿이 있어서 그냥 자동으로 만들어지지만

WPF client에서 Protos에 greet.proto를 복사하고 따라했지만 빌드에러가 났다..

 

구글 검색후 해결했다

 

https://stackoverflow.com/questions/60810497/grpc-erros-in-wpf-net-core

 

gRPC erros in WPF .NET Core

I want to create a simple WPF Core, gRPC project. This "code" works perfectly in my .NET Core Console app, however WPF seems to be something special. Proto File syntax = "proto3"...

stackoverflow.com

 

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
    <CoreCompileDependsOn>$(CoreCompileDependsOn);Protobuf_Compile</CoreCompileDependsOn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Google.Protobuf" Version="3.23.2" />
    <PackageReference Include="Grpc.Net.Client" Version="2.53.0" />
    <PackageReference Include="Grpc.Tools" Version="2.54.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <Protobuf Include="Protos\greet.proto" GrpcServices="Client" />
    
  </ItemGroup>

</Project>

 

프로젝트 편집에서

 

<CoreCompileDependsOn>$(CoreCompileDependsOn);Protobuf_Compile</CoreCompileDependsOn>

이걸 추가함으로써 빌드가 되었다.

 

 

'wpf' 카테고리의 다른 글

[WPF] 체크박스 xName을 이용하여 반복작업 하지 않고 간결하게  (0) 2023.06.09
MEF란?  (0) 2023.06.08
dynamic property 에서 Set을 할떄  (0) 2022.12.05
public (string name, int age) GetUser()  (0) 2022.10.26
PeriodicTimer  (0) 2022.08.31
Posted by 동동(이재동)
wpf2022. 12. 5. 11:44

await SendConfirmMsg(msgSplit, DataManager.LocalData.LongTrendBuy, "QuitRange");

 

 

 

private static async Task SendConfirmMsg(string[] msgSplit, dynamic data, string prop)
        {
            double numValue;
            bool isNum = double.TryParse(msgSplit[2], out numValue);

            data.GetType().GetProperty(prop).SetValue(data, numValue, null);           

            DataManager.Instance.SaveData();
            await TelegramPushService.SendMessage($"{msgSplit[0]} {msgSplit[1]} {numValue}");
        }

 

 

이런식으로 반복되는 구문을 dynamic을 이용해서 짧게 만들수 있다.

 

중요

 

data.GetType().GetProperty(prop).SetValue(data, numValue, null);   

 

참고

https://stackoverflow.com/questions/12970353/c-sharp-dynamically-set-property

'wpf' 카테고리의 다른 글

MEF란?  (0) 2023.06.08
[WPF] gRPC Client 빌드 안될때 대처법  (0) 2023.06.07
public (string name, int age) GetUser()  (0) 2022.10.26
PeriodicTimer  (0) 2022.08.31
2개의 LIST 비교 하는것  (0) 2021.11.18
Posted by 동동(이재동)
wpf2022. 10. 26. 15:34

Tuple 대신에 이렇게 사용할수도 있다 엄청 편리할듯

 

public (string name, int age) GetUser()
        {
            return ("이름", 30);
        }

'wpf' 카테고리의 다른 글

[WPF] gRPC Client 빌드 안될때 대처법  (0) 2023.06.07
dynamic property 에서 Set을 할떄  (0) 2022.12.05
PeriodicTimer  (0) 2022.08.31
2개의 LIST 비교 하는것  (0) 2021.11.18
싱글톤 쓰기  (0) 2021.08.24
Posted by 동동(이재동)
wpf2022. 8. 31. 16:03

PeriodicTimer는 비동기 방식으로 타이머 틱을 처리하는 최신 타이머 API 입니다. 다음처럼 사용할 수 있고요,

var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));

while (await timer.WaitForNextTickAsync())
{
    Console.WriteLine(DateTime.Now);
}

1초 간격으로 실행되는 결과를 확인할 수 있습니다.

| 실행 결과

2021-11-18 오후 11:14:17
2021-11-18 오후 11:14:18
2021-11-18 오후 11:14:19
2021-11-18 오후 11:14:20
2021-11-18 오후 11:14:21

얼핏 보면 Task.Delay()의 기능과 별반 차이가 없어 보이죠? 차이가 있습니다. 다음의 코드를 보시죠.

var timer = new PeriodicTimer(TimeSpan.FromSeconds(2));

while (await timer.WaitForNextTickAsync())
{
    Console.WriteLine($"Wake Up!: {DateTime.Now}");

    // 1500 ms 소요되는 처리가 발생했다고 가정
    Thread.Sleep(1500);
}

| 실행 결과

Wake Up!: 2021-11-18 오후 11:18:56
Wake Up!: 2021-11-18 오후 11:18:58
Wake Up!: 2021-11-18 오후 11:19:00
Wake Up!: 2021-11-18 오후 11:19:02
Wake Up!: 2021-11-18 오후 11:19:04

강제로 1500 ms 만큼의 딜레이를 줬음에도 불구하고 지정한 period 만큼의 타이머 틱을 제공합니다.

타이머 동작 중 취소하는 기능이 있을까요? WaitForNextTickAsync(cancellationToken)를 통해 취소도 가능합니다. 하지만 좀 더 쉽게 취소하는 방법은 timer를 Dispose하는 것입니다.

'wpf' 카테고리의 다른 글

dynamic property 에서 Set을 할떄  (0) 2022.12.05
public (string name, int age) GetUser()  (0) 2022.10.26
2개의 LIST 비교 하는것  (0) 2021.11.18
싱글톤 쓰기  (0) 2021.08.24
Combox 에 Enum 바인딩  (0) 2021.05.06
Posted by 동동(이재동)
wpf2021. 11. 18. 18:01

private bool IsDiffList<T>(List<T> list1, List<T> list2)
        {
            var diff1 = list1.Except(list2);
            var diff2 = list2.Except(list1);

            var resultDiff = diff1.Concat(diff2).ToList();

            if (resultDiff.Count > 0)
                return true;
            else
                return false;
        }

 

if (IsDiffList<OrderInfo>((xProfitOrderListbox.ItemsSource as List<OrderInfo>).ToList(), _service.OrderInfoList))
                {
                    xProfitOrderListbox.ItemsSource = _service.OrderInfoList;
                    xProfitOrderListbox.Items.Refresh();
                }

 

이런식으로 반복적으로 item을 넣어야 하는곳에 넣어준다. timer를 이용하면 객체를 계속 생성하기때문에

 

무조건 넣어주면 메모리 Leak 이 걸린다. 그렇기 떄문에 변경될때만 적용되게 해야한다.

'wpf' 카테고리의 다른 글

public (string name, int age) GetUser()  (0) 2022.10.26
PeriodicTimer  (0) 2022.08.31
싱글톤 쓰기  (0) 2021.08.24
Combox 에 Enum 바인딩  (0) 2021.05.06
WPF에서 기본적으로 제공해주는 BoolToVisConverter 컨버터  (0) 2020.04.28
Posted by 동동(이재동)
wpf2021. 8. 24. 12:13

 public abstract class Singleton<T> where T : class
    {
        private static readonly Lazy<T> LazyInstance =
            new Lazy<T>(CreateInstanceOfT, LazyThreadSafetyMode.ExecutionAndPublication);

        public static T Instance
        {
            get
            {
                return Singleton<T>.LazyInstance.Value;
            }
        }

        private static T CreateInstanceOfT()
        {
            return Activator.CreateInstance(typeof(T), true) as T;
        }
    }

 

출처 : http://egloos.zum.com/sweeper/v/3157853

Posted by 동동(이재동)
wpf2021. 5. 6. 18:31

 

출처 stackoverflow.com/questions/58743/databinding-an-enum-property-to-a-combobox-in-wpf

Posted by 동동(이재동)
wpf2020. 4. 28. 12:39

Converter={StaticResource BoolToVisConverter}

 

 

단 App.xaml에

<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />

를 추가해야한다.

 

구지 안만들어도 된다 ㅋ

Posted by 동동(이재동)
wpf2020. 3. 6. 17:53

WPF에서 텝이 변결될 때 발생하는 이벤트 키워드인 SelectionChanged를 TabControl에 사용해서 탭을 가져오는 형태로 코드구성을 진행하는 중 이상한 점이 발견됬다.

내가 만드는 프로그램에서는 2번째 탭을 클릭하면 SelectionChanged가 호출 되고 2번째 탭 내의 ListBox 컨텐츠가 업데이트 되는 형식으로 코드가 진행될 것으로 예상하고 디버그를 하였으나, 실제로는 2번째 탭을 클릭하면 SelectionChanged가 재귀적으로 무한호출 되버리는 문제가 발생되었다.

문제는 TabControl 내부에 컨텐츠가 업데이트 되거나 무슨 변화가 존재할 경우에도 해당 이벤트가 호출된다는 점이다. 이럴 대는 Source 값이 TabControl인지 비교하는 항목이 추가되야 하며 아래와 같은 코드구성이 가능하다.

private void MainTabChanged(object sender, SelectionChangedEventArgs e)
{
int tabItem = ((sender as TabControl)).SelectedIndex;
if (e.Source is TabControl) // This is a soultion of those problem.
{
switch (tabItem)
{
case 0: // Chatting
Debug.WriteLine("Tab: Chatting");
if (MainChatList.Items.Count > 0)
{
MainChatList.SelectedIndex = MainChatList.Items.Count - 1;
MainChatList.ScrollIntoView(MainChatList.Items[MainChatList.Items.Count - 1]);
}
break;
case 1: // Users
Debug.WriteLine("Tab: Users");
break;
case 2: // Friends
Debug.WriteLine("Tab: Friends");
this.OnFriendTabActive();
break;
default:
Debug.WriteLine("Tab: " + tabItem);
break;
}
}
}

 

소스의 4번째 줄을 확인하면 TabControl의 문제점을 개선하는 코드를 확인 할 수 있다.

 

 

if (e.Source is TabControl)<--로 확인가능

Posted by 동동(이재동)
wpf2019. 4. 24. 12:33


        public static event EventHandler MainPageMessageEvent
        {
            add
            {
                if (_mainPageMessageEvent == null || _mainPageMessageEvent.GetInvocationList().Count() == 0)
                    _mainPageMessageEvent += value;
            }

            remove
            {
                _mainPageMessageEvent -= value;
            }
        }

 

 

 

Posted by 동동(이재동)
wpf2019. 3. 21. 17:44

List를 그대로 대입시켜버리면 해당 객체가 바뀌기때문에


clone, deep copy를 해야한다.


List<Book> books_2 = books_1.ConvertAll(book => new Book());



내가 봤을때는 이게 가장 나은 방법같다.

https://stackoverflow.com/questions/14007405/how-create-a-new-deep-copy-clone-of-a-listt

Posted by 동동(이재동)
wpf2019. 2. 26. 16:56

얼굴 인식 2번쨰

Face API를 항상 호출하면 1분에 20번(무료 버전 기준) 호출 제한을 넘기때문에

일단 openCV 에서 얼굴을 최대한 감지한후 호출을 해야 호출 제한에 어느정도 자유롭다.

일단 openCVSharp을 설치하면

CascadeClassifier class의 DetactMultiScale을 이용해서 사람 얼굴을 감지할수 있다.

private readonly CascadeClassifier _localFaceDetector = new CascadeClassifier();
_localFaceDetector.Load("Data/haarcascade_frontalface_alt.xml");

_grabber.NewFrameProvided += (s, e) =>
{
var rects = _localFaceDetector.DetectMultiScale(e.Frame.Image, 1.3, 1, 0, new OpenCvSharp.Size(200, 200));
.
.
//Face API를 이용해서 얼굴 찾기

이런식으로 1차적으로 openCV 얼굴 검출 2차 Face API를 이용해서 얼굴 찾기 하면 된다.

프레임별로 얼굴을 찾는 부분을 호출 하기 때문에 2초 정도 안에는 다시 FaceAPI를 호출하지 못하도록 구현해야한다.


DetectMultiScale을 이용해서 검출할수 있는 최대 인원 및 최소 사이즈를 설정할수 있다. 샘플에서는 얼굴 크기가 200 이상인사람만 찾도록 구현했다.

샘플은 웹캠이 구동되고 얼굴을 비추면 첨보는 사람면 등록을 , 등록된 사람이면 userData의 이름 및 성별등등을 출력해준다. Face API는 최대한 호출되지 않도록 openCV에서 얼굴이 완전히 검출 되었을때만 사용했다.


FaceApiTest2.zip













Posted by 동동(이재동)
wpf2019. 2. 25. 15:34

  Face api 1.0 


https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250

face api를 사용하기 위해선 face api를 사용하기 위한 key와 End Point를 받아야 한다.

end point는 이런식으로 되어 있다.
https://koreacentral.api.cognitive.microsoft.com/face/v1.0/

나머지는 api 사용법대로 사용 하면 된다.


openCV를 이용해서 카메라를 띄우고 FrameGrabber를 이용해서 해당이미지 사진을 올린다.

원리는 이렇다

FaceDetect를 이용해서 사람을 찾고 찾을경우 Find similer를 이용하여 FaceList에서 검색한다.

만약 없을경우 add Face를 이용하여 사람을 등록한다. 그룹을 이용해서 할수도 있다.

나머진 샘플을 이용해보자


FaceApiTest.zip


Posted by 동동(이재동)
wpf2019. 2. 14. 15:34

Libox를 감싸는 패널에  StackPanel이 있으면 안된다.


 Grid를 사용해야 하며 


만약 WrapPanel을 이용할경우


ControlTemplate대신 ItemPanelTemplate을 이용해야한다.




Posted by 동동(이재동)
wpf2019. 1. 22. 16:37


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        private int index = 0;
        private ObservableCollection<FranchiseModel> list = new ObservableCollection<FranchiseModel>();
 
        public void Next()
        {
            list.Clear();
 
            while (list.Count < 3)
            {
                list.Add(Data[index]);
                index++;
 
                if (index >= Data.Count)
                {
                    index = 0;
                }
            }
 
            FranchiseLists = list;
        }



예를들어 Data에는 10개의 값이 있고 


list에는 3개씩 꽉차게 보여주고 싶다 하면


인덱스를 봤을때

0,1,2 3,4,5 6,7,8 9,10,0


이렇게 10개가 찼을때 다시 젤첨의 0번째 인덱스를 보여주게 함으로써 빈값이 없게 만든다.


list를 항아리라 생각하면 쉽다. while문을 돌면서 무조건 3개를 차게 한다.


이렇게 하면 만약 항상 list는 3개가 되기때문에 빈칸없는 정보를 보여줄때 쓰면 좋다.



Posted by 동동(이재동)
wpf2018. 11. 13. 16:20


namespace WpfRadioButton
{
    using System;
    using System.ComponentModel;
    using System.Globalization;
    using System.Windows;
    using System.Windows.Data;
    using System.Windows.Markup;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ViewModel vm = new ViewModel();
        public MainWindow()
        {
            InitializeComponent();

            DataContext = vm;
        }
    }

    [ValueConversion(typeof(bool), typeof(Enum))]
    public class EnumToBoolExtension : MarkupExtensionIValueConverter
    {
        #region IValueConverter
        
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return parameter.Equals(value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ((bool) value) == true ? parameter : DependencyProperty.UnsetValue;
        }

        #endregion

        #region MarkupExtension

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }

        #endregion
    }

    public enum Direction
    {
           North,
        Easth,
        West,
        South
    }

    public class ViewModel : INotifyPropertyChanged
    {
        public Direction direction;

        public Direction Direction
        {
            get
            {
                return this.direction;
            }

            set
            {
                this.direction = value;
                this.RaisePropertyChanged("Direction");
            }
        }

        #region NotifyPropertyChanged Methods

        public void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;

            if (handler != null)
            {
                handler(thisnew PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}


<Window x:Class="WpfRadioButton.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:local="clr-namespace:WpfRadioButton"
        Title="RadioButton" Height="200" Width="300">
    <Grid DataContext="{Binding}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <RadioButton Grid.Row="0" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="North" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.North}}"/>
        <RadioButton Grid.Row="1" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="East" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.Easth}}"/>
        <RadioButton Grid.Row="2" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="West" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.West}}"/>
        <RadioButton Grid.Row="3" GroupName="directionText" Margin="5" VerticalAlignment="Center" Content="South" 
                     IsChecked="{Binding Direction, Converter={local:EnumToBool}, ConverterParameter={x:Static local:Direction.South}}"/>
        <TextBlock Grid.Row="4" Margin="5" VerticalAlignment="Center" Text="{Binding Direction}"/>
    </Grid>
</Window>

출처 : https://zamjad.wordpress.com/2014/03/01/radio-button-in-mvvm/

Posted by 동동(이재동)
wpf2018. 10. 23. 09:48
<ScrollViewer PanningMode="Both" x:Name="ScrollViewer"ManipulationBoundaryFeedback="ScrollViewer_ManipulationBoundaryFeedback">
    <StackPanel Width="300">
    </StackPanel>
</ScrollViewer>



private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
    e.Handled = true;
}


Posted by 동동(이재동)
wpf2018. 8. 31. 12:53
public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
 
        protected override void OnSourceInitialized(EventArgs e)
        {
            IconHelper.RemoveIcon(this);
        }
    }



public static class IconHelper
    {
        [DllImport("user32.dll")]
        static extern int GetWindowLong(IntPtr hwnd, int index);
 
        [DllImport("user32.dll")]
        static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
 
        [DllImport("user32.dll")]
        static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, 
                   int x, int y, int width, int height, uint flags);
 
        [DllImport("user32.dll")]
        static extern IntPtr SendMessage(IntPtr hwnd, uint msg, 
                   IntPtr wParam, IntPtr lParam);
 
        const int GWL_EXSTYLE = -20;
        const int WS_EX_DLGMODALFRAME = 0x0001;
        const int SWP_NOSIZE = 0x0001;
        const int SWP_NOMOVE = 0x0002;
        const int SWP_NOZORDER = 0x0004;
        const int SWP_FRAMECHANGED = 0x0020;
        const uint WM_SETICON = 0x0080;
 
        public static void RemoveIcon(Window window)
        {
            // Get this window's handle
            IntPtr hwnd = new WindowInteropHelper(window).Handle;
 
            // Change the extended window style to not show a window icon
            int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
 
            // Update the window's non-client area to reflect the changes
            SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | 
                  SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
        }
 
    }


Posted by 동동(이재동)
wpf2018. 8. 29. 17:25

app.xaml.cs 에서 onStartup에서 


RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;


렌더모드를 소프트웨어 온리로 바꿨더니


Mediaelement 의 4k GPU 사용량이 100에서 많이 줄어들었다.


DID같은경우는 너무 GPU가 높으니 하드웨어 렌더링보다는 소프트웨어 렌더링을 이용해야겠다.



참고 : https://blogs.msdn.microsoft.com/jgoldb/2010/06/22/software-rendering-usage-in-wpf/



Posted by 동동(이재동)
wpf2018. 8. 7. 12:23
<Viewbox StretchDirection="DownOnly" >
     <Label Content="Enable" FontSize="10" FontStretch="Normal" />
</Viewbox>


'wpf' 카테고리의 다른 글

WPF Title Icon 제거하기  (0) 2018.08.31
WPF 강제 소프트웨어 렌더링 설정  (0) 2018.08.29
WPF에서 GIF 돌리기 컨트롤  (1) 2018.05.02
Xaml에 Binding을 하지 않고 컨버터를 쓰고 싶을때  (0) 2018.03.07
wpf FlipView  (0) 2017.10.19
Posted by 동동(이재동)
wpf2018. 5. 2. 17:34


샘플 소스 참조~


WpfAnimatedGif-master.zip


Posted by 동동(이재동)
wpf2018. 3. 7. 17:34

대부분 컨버터는 바인딩을 걸고 쓰지만 아래와 같이 영문버전 한글버전 식으로 컨버터를 쓰고 싶다면

이미지소스 에 바인딩을 걸어 버리면 된다.



1
2
3
4
5
 <Image  Stretch="None" Visibility="{Binding IsShowInfoWordImage, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Image.Source>
                            <Binding Source="/BANAPRESSO_KIOSK;component/Images/order_list_info_words.png" Converter="{StaticResource GlobalImageNameConverter}" />
                        </Image.Source>
</Image>

Posted by 동동(이재동)
wpf2017. 10. 19. 16:27

https://www.codeproject.com/Articles/741026/WPF-FlipView


나중에 정리

Posted by 동동(이재동)
wpf2017. 9. 12. 12:40

listview
1
2
3
4
5
6
7
8
9
10
11
12
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListViewItem}">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>


button


1
2
3
4
5
6
7
8
9
10
11
12
13
14
 <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="Background" Value="Transparent"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Border Background="{TemplateBinding Background}">
                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
</Button.Style>


Posted by 동동(이재동)
wpf2017. 9. 6. 12:13

예를 들면 3이라는 숫자가 바인딩 되어 있고

이걸 3개월로 바꾸고 싶으면 Converter를 쓰면 되지만 일일이 만들기가 엄청 귀찮다


 <TextBlock Text="{Binding Month, StringFormat={}{0}개월}"/>


돈도 

<TextBlock Text="{Binding Money,StringFormat='##,#'}" />


이렇게 하면 300,000 형식으로 나온다.



Posted by 동동(이재동)
wpf2017. 8. 22. 12:41

물론 ViewModel에서는 MVVM Light 라이브러리에 있는 NotifyProperty가 알아서 해주겠지만


Model 같은경우는 자기가 만들면 된다.


에를 들면 ObservableCollection에서 어떤 Property를 수정하였을때 즉각적으로 바인딩된 UI에 적용하고 싶다면


Model에 INotifyPropertyChanged 인터페이스를 구축하면 된다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    public class OrderedMenuItem : INotifyPropertyChanged
    {
        public int Index { get; set; }
 
        private int _orderCount;
 
        public int OrderCount
        {
            get { return _orderCount; }
            set
            {
                if (_orderCount != value)
                {
                    _orderCount = value;
                    NotifyPropertyChanged("OrderCount");
                }
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        public void NotifyPropertyChanged(string propName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(thisnew PropertyChangedEventArgs(propName));
        }
    }


참고 : http://www.wpf-tutorial.com/data-binding/responding-to-changes/


Posted by 동동(이재동)