WPF: One-way IValueConverter
-
23-09-2019 - |
문제
From what I've been told, I need to create an IValueConverter
to do my custom formatting. The problem is my formatting is one-way, there is no legitmate ConvertBack
implementation.
So, how do I handle one-way IValueConverter
s. (If it helps, this is for a read-only control.)
해결책
C 럼 ID_CAT에 의해 실현 된 원형 참조가있는 카테고리 테이블이 올바르게 이해할 수 있습니다.
다음 모델은 예상대로 작동해야합니다.
class Category < ActiveRecord::Base
belongs_to :supercategory, :class_name => "Category", :foreign_key => "cat_id"
has_many :subcategories, :class_name => "Category", :foreign_key => "cat_id"
end
.
categories
테이블이 보이는 경우 :
id | name | cat_id
---------------------------
1 | cat 1 | null
2 | cat 1.1 | 1
3 | cat 1.2 | 1
4 | cat 2 | null
5 | cat 1.2.1 | 3
.
Category.find(1).subcategories
는 cat 1.1
및 cat 1.2
객체가있는 배열을 반환합니다.
Category.find(1).supercategory
는 nil
를 반환합니다
Category.find(3).supercategory
는 cat 1
객체를 반환합니다
Category.find(4).supercategory
는 nil
를 반환합니다
...
제휴하지 않습니다 StackOverflow