zoukankan      html  css  js  c++  java
  • Listbox简单用法

    <ListBox x:Name="ListBoxPatientAllergy" Grid.Row="1"
    ItemContainerStyle="{StaticResource ListboxStyle}"
    Background="Transparent" BorderThickness="0"
    Foreground="Black"
    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
    ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.PanningMode="None"
    ItemsSource="{Binding Path=PatientAllergyEntityList}">
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="100"/>
    <ColumnDefinition Width="170"/>
    <ColumnDefinition Width="80"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <sync:DateTimeEdit x:Name="dpPatientAllergy"
    Height="28" Width="100" Margin="0,0,0,5"
    DateTime="{Binding Path=Date, Mode=TwoWay}"
    CustomPattern="dd MMM yyyy"
    MinDateTime="01 Jan 1800"/>

    <TextBox Name="TxtPatientAllergy" Grid.Column="1"
    HorizontalAlignment="Stretch" Height="28"
    MaxLength="100" Margin="2,0,0,5" VerticalContentAlignment="Center"
    Validation.Error="Validation_Error"
    Text="{Binding Path=Description,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>

    <ComboBox Name="CmbPatientAllergy" Grid.Column="2" VerticalContentAlignment="Center"
    ItemContainerStyle="{StaticResource ComboBoxItemStyle}"
    Background="White" Margin="2,0,0,5" Height="28"
    ItemsSource="{Binding RelativeSource={RelativeSource Findancestor, AncestorType={x:Type UserControl}}, Path=DataContext.CodeTables.CTPatientAllergyStatusEntityList}"
    DisplayMemberPath="DisplayValue"
    SelectedValuePath="PatientAllergyStatusID"
    SelectedValue="{Binding Path=PatientAllergyStatusFK, Mode=TwoWay}"/>

    <Button x:Name="BtnDeletePatientAllergy" Grid.Column="3"
    Margin="2,2,2,5" BorderThickness="0" BorderBrush="White" HorizontalAlignment="Center"
    Height="28" Width="30"
    Click="BtnDeletePatientAllergy_Click">
    <Button.Template>
    <ControlTemplate TargetType="Button">
    <Image Width="24" Height="24"
    HorizontalAlignment="Center" VerticalAlignment="Center"
    Source="pack://application:,,,/Medisys.SEMR.WPFClient.Controls.Resource;component/Image/DeleteIcon.png" />
    </ControlTemplate>
    </Button.Template>
    </Button>
    </Grid>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>

    事件:

    private void BtnDeletePatientAllergy_Click(object sender, RoutedEventArgs e)
    {
    object obj = ((Button)sender).DataContext;

    if (obj == null)
    return;
    else
    {

    PatientAllergyEntity PatientAllergyEntity = obj as PatientAllergyEntity;

    if (PatientAllergyEntityList != null
    && PatientAllergyEntity.PatientAllergyID != null && PatientAllergyEntity.PatientAllergyID != Guid.Empty)
    {
    PatientAllergyEntityList.Remove(PatientAllergyEntity);
    }

    }
    }

  • 相关阅读:
    mysql 去除重复数据
    linux 相关命令
    mysql load data infile auto increment id
    《Head First 设计模式》读书笔记
    《NoSQL精粹》读书笔记
    linux 服务器丢包故障排查
    《高性能MySQL》 读书总结
    NAT穿透(UDP打洞)
    python函数调用关系图(python call graph)
    VMware 三种网络模式
  • 原文地址:https://www.cnblogs.com/zhaowei303/p/4794176.html
Copyright © 2011-2022 走看看