XamPropertyGrid自定义编辑器(绑定)不起作用(XamPropertyGrid Custom Editor (Binding) not working)
我在C#WPF中使用Infragistics的“XamPropertyGrid”,我创建了两个类如下:
public class ClassA { public ClassB B { get; set; } } public class ClassB { public bool C { get; set; } }
目标是为PropertyGrid创建一个自定义编辑器,其中包含一个Checkbox控件并设置ClassA实例的Property BC
这是我的xaml代码:
<ig:XamPropertyGrid x:Name="pGrid"> <ig:XamPropertyGrid.EditorDefinitions> <ig:PropertyGridEditorDefinition> <ig:PropertyGridEditorDefinition.TargetProperties> <system:String>B</system:String> </ig:PropertyGridEditorDefinition.TargetProperties> <ig:PropertyGridEditorDefinition.EditTemplate> <DataTemplate> <CheckBox Content="XYC" IsChecked="{Binding Value.C}"></CheckBox> </DataTemplate> </ig:PropertyGridEditorDefinition.EditTemplate> </ig:PropertyGridEditorDefinition> </ig:XamPropertyGrid.EditorDefinitions> </ig:XamPropertyGrid>
首先,我为PropertyGrid设置所选对象,如下所示:
public MainWindow() { InitializeComponent(); ClassA a = new ClassA(); a.B = new ClassB(); pGrid.SelectedObject = a; }
但是当我检查Checkbox时,Property C不会改变。 至于我调试了编辑器DataTemplate中的Value属性为null。 (我在Binding中放了一个转换器来检查它。)
先谢谢你。
I am using Infragistics' "XamPropertyGrid" in C# WPF, I have created two classes as follow:
public class ClassA { public ClassB B { get; set; } } public class ClassB { public bool C { get; set; } }
The Goal is to create a Custom Editor for PropertyGrid that contains a Checkbox Control and sets Property B.C of an instance of ClassA
Here is my xaml code:
<ig:XamPropertyGrid x:Name="pGrid"> <ig:XamPropertyGrid.EditorDefinitions> <ig:PropertyGridEditorDefinition> <ig:PropertyGridEditorDefinition.TargetProperties> <system:String>B</system:String> </ig:PropertyGridEditorDefinition.TargetProperties> <ig:PropertyGridEditorDefinition.EditTemplate> <DataTemplate> <CheckBox Content="XYC" IsChecked="{Binding Value.C}"></CheckBox> </DataTemplate> </ig:PropertyGridEditorDefinition.EditTemplate> </ig:PropertyGridEditorDefinition> </ig:XamPropertyGrid.EditorDefinitions> </ig:XamPropertyGrid>
At the start, I set the selected object for PropertyGrid like this:
public MainWindow() { InitializeComponent(); ClassA a = new ClassA(); a.B = new ClassB(); pGrid.SelectedObject = a; }
But when I check the Checkbox, Property C won't change. As far as I debugged the Value property inside Editor DataTemplate is null. (I put a converter inside Binding to check that.)
Thank you in Advance.
原文:https://stackoverflow.com/questions/34245580
最满意答案
这工作:
perl -p -i -e 's/(<langSet xml.lang=....>)\s*<tig>(.*?)<\/tig>\s*<tig>/\1<tig>\2<\/tig>\1<tig>/g while m/(<langSet xml.lang=....>)\s*<tig>(.*?)<\/tig>\s*<tig>/gi' iate.dsl
This worked:
perl -p -i -e 's/(<langSet xml.lang=....>)\s*<tig>(.*?)<\/tig>\s*<tig>/\1<tig>\2<\/tig>\1<tig>/g while m/(<langSet xml.lang=....>)\s*<tig>(.*?)<\/tig>\s*<tig>/gi' iate.dsl
相关问答
更多-
单线是SASS(One-liner is SASS)[2022-02-24]
Sass语法主要基于缩进和换行,所以在Sass中确实是六行(每个规则两个,不包括空行): .apple background-image: url('apple.png') .orange background-image: url('orange.png') .pear background-image: url('pear.png') 据我所见,你无法将这些人凝聚到萨斯的单线队员身上。 Sass syntax is principally based on indentat ... -
perl -pe's/\D*(\d+).*/$1/' 要么 perl -nE'/\d+/&&say$&' 要么 perl -nE'say/(\d+)/' 要么 perl -ple's/\D//g' 或者可能 perl -nE'$,=" ";say/\d+/g' perl -pe's/\D*(\d+).*/$1/' or perl -nE'/\d+/&&say$&' or perl -nE'say/(\d+)/' or perl -ple's/\D//g' or may be perl -n ...
-
backtick语法调用一个shell,并在被调用时,shell假定它应该插入传递的字符串。 一个更清晰的语法可能是: system('perl -pli -e "s/\s*$//" tape.txt'); 由于您没有捕获命令的输出,因此使用反引号或qx代替system不是问题。 另外,添加-l开关可以自动读取每一行,然后添加一个换行符 - 可能是您想要的。 The backtick syntax invokes a shell and when invoked, the shell assumes it ...
-
/e开关将replace表达式转换为常规perl表达式。 你需要引用' MB'并使用连接( . )。 's#(\d+)(\s+SELECT)#$1/(1024*1024*2) . q[ MB] . $2#e 应该管用。 The /e switch turns the replace expression into a regular perl expression. You need to quote the ' MB' and use concatenation (.) . 's#(\d+)(\s+SE ...
-
不要使用glob rename 。 使用标量。 尝试在替换之前将文件名分配给新变量,并将旧名称重命名为修改后的名称,如下所示: perl -e'while(<*.JPG>) { ($new = $_) =~ s/JPG$/jpg/; rename $_, $new }' 用ls -1检查输出: IMG_0178.jpg ...
-
蟒蛇单行(python one-liner)[2022-11-02]
sum()调用不需要加倍 total = sum(v.amount for ob in self.oblist for v in ob.anotherob) No need to double up on the sum() calls total = sum(v.amount for ob in self.oblist for v in ob.anotherob) -
可以Encode做你想要的吗? 然后,您可能必须在脚本中使用encode()和decode() ,因此它可能不会短于: perl -nE 'BEGIN {binmode STDIN, ":encoding(utf16)" } ; ...' 有一个PERL_UNICODE环境变量,但它是相当有限的:它只是模仿-C如果我记得正确。 我曾经试图找出为什么不存在用于“流行”形式的UTF的-C开关,并且它似乎归结为它们是否经常被使用; 是或不是很好理解(endianness有时数 - 谁知道?); 是 - ...
-
嗯,简单的解决方案是将所有换行符和管道转换为选项卡。 这听起来有点疯狂,但乍一看,它听起来像你想要的: perl -pwe 'tr/\n|/\t\t/' yourfile.txt 但是有一些东西与你的问题描述不符。 你说: 我有一个包含成对行的文件 这意味着您的文件实际上看起来像这样: FIRST PIECE OF INFO PIECE 2 | PIECE 3 | PIECE 4 | ... SECOND PIECE OF INFO PIECE 2a | PIECE 3b | PIECE 4b | ... ...
-
Perl单线重复替换(Perl one-liner repeat substitution)[2022-07-27]
这工作: perl -p -i -e 's/()\s* (.*?)<\/tig>\s* /\1 \2<\/tig>\1 /g while m/( )\s* (.*?)<\/tig>\s* /gi' iate.dsl This worked: perl -p -i -e 's/( )\s* (.*?)<\/tig>\s* ... -
你已经用^锚定了替换。 由于Vim如何进行替换,它将从最后一场比赛结束时寻找下一场比赛。 改为使用后视: :%s/\v(^\s*)@<= {4}/\t/g 有关更多帮助请参阅: :h /\@<= You have anchored you substitution with ^. Because of how Vim does substitution's it will look for the next match from the end of the last match. Use a look ...