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

    }
    }

  • 相关阅读:
    JS小白进阶之路(2)
    JS小白进阶之路(1)
    ajax.readyState与ajax.status一览
    Photoshop投影和CSS box-shadow转换
    layer弹层插件
    [Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted
    css清除浮动影响
    css网页重置样式表(多版本)
    XSS攻击和CSRF攻击的定义及区别
    git的cd命令
  • 原文地址:https://www.cnblogs.com/zhaowei303/p/4794176.html
Copyright © 2020-2023  润新知