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);
    }

    }
    }

  • 相关阅读:
    C# 使用PictureBox控件--点击切换图片
    C# 点击窗口任意位置拖动
    File类
    Path类
    ArrayList集合-[习题]--C#
    ArrayList集合-[长度问题]--C#
    ArrayList集合--C#
    c# winform 弹出确认消息框判断是否删除?
    C# 文件与目录的基本操作(System.IO)
    SQL Server事务处理
  • 原文地址:https://www.cnblogs.com/zhaowei303/p/4794176.html
Copyright © 2011-2022 走看看