我有下面的字典:
Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("1|1", "blue");
test.Add("1|2", "Nice");
test.Add("1|3", "Jaish");
test.Add("2|2", "Muna");
test.Add("3|1", "haha");
test.Add("3|2", "green");
test.Add("4|1", "red");
Dictionary<string, string> test2 = new Dictionary<string, string>();
foreach (KeyValuePair<string, string> entry in test)
{
if (!test2.ContainsValue(entry.Key))
test2.Add(entry.Key, entry.Key);
}
Run Code Online (Sandbox Code Playgroud)
我想删除以下重复值:
test.Add("1|2", "Nice");
test.Add("1|3", "Jaish");
test.Add("3|2", "green")
Run Code Online (Sandbox Code Playgroud)
因此,删除重复项后,Dictionary密钥计数应为4.
我有下拉和网格.在网格列中有超链接.如果Dropdown集合包含1个项目,则下拉列表应该是不可见的.我需要一个逻辑来将Visibility绑定到项目集合.
这是GRid中一个超链接的XAML.
<!--Associate-->
<TextBlock Margin="10, 0, 0, 0">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource courseListVisibilityConverter}"
ConverterParameter="Associate">
<Binding Path="IsCourseAssocited"
RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type DPA2:TakenCoursesNotApplied}}" />
<Binding Path="DataContext"
RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</TextBlock.Visibility>
<Hyperlink DataContext="{Binding}"
Name="Associate"
IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TextBlock}}, Path=IsVisible}"
Click="Associate_Click">
<TextBlock TextWrapping="Wrap"
Text="Associate" />
</Hyperlink>
</TextBlock>
public class CourseListVisibilityConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || value[0] == null || value[1] == null) return Visibility.Collapsed;
bool IsEditMode = value[0] == DependencyProperty.UnsetValue ? …Run Code Online (Sandbox Code Playgroud) 任何机构可以建议REGX低于日期范围
格式为CCYYMMDD 19000101至20001231空白
我是REGX的新手,请帮帮我.