我有这个组合框,我想在其中添加按钮作为项目.但是,当我从组合框中选择按钮并单击按钮时,不会执行该操作.组合框的列表相反.该怎么做?如果这是不可能的,我想我只需要即兴发挥.建议将不胜感激.谢谢!
<ComboBox>
<ComboBoxItem Name="Item1">
<Button Name="Button1" Click="Button1_OnClick">first button</Button>
</ComboBoxItem>
<ComboBoxItem Name="Item2">
<Button Name="Button2" Click="Button2_OnClick">second button</Button>
</ComboBoxItem>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
我有这个文本块
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}, {1}, {2}, ">
<Binding Path="object.strProp1" />
<Binding Path="object.strProp2" />
<Binding Path="object.strProp3" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
假设object不为 null 且*strProp1* = "strProp1"
、*strProp2* = "strProp2"
、 和*strProp2* = "strProp2"
。
其输出将是这样的:
strProp1, strProp2, strProp3,
Run Code Online (Sandbox Code Playgroud)
我想知道的是,每当对象为空或属性之一为空时,如何删除“,”。也就是说,如果object为 null,则 Textblock 将为空。或者,如果其中一个对象是空的,那么它就只是空的。
关于如何做到这一点有什么建议吗?谢谢!编辑:最好仅在 xaml 中:)