zoukankan      html  css  js  c++  java
  • 可以binidng属性的属性【项目】

    1:binding后台bool[]数据以及后台ObservableCollection数据

    分别见下面xaml的VisibilityText的Binding

    public bool[] RubberTypeLegends
            {
                get
                {
                    bool[] result = new bool[] {false,false,false };
                    for (int i = 0; i < ResultItems.Count; i++)
                    {
                        result[i] = true;
                    }
                    return result;
                }
            }
    ...
    <StackPanel x:Name="OSL_Legend"
                            Margin="30,0,0,0"
                            Orientation="Horizontal"
                            Visibility="{Binding RubberTypeLegends[1],
                                                 Converter={StaticResource boolToVisibilityConverter}}">
                    <Rectangle Width="10"
                               Height="10"
                               Fill="Blue" />
                    <TextBlock Margin="5,0,0,0"
                               FontSize="9pt"
                               Style="{StaticResource Univers57_Condensed}"
                               Text="{Binding ResultItems[1].RubberType}" />
                </StackPanel>
    ...
    private ObservableCollection<OilSwellResultsItemViewModel> _resultItems;
    
            public ObservableCollection<OilSwellResultsItemViewModel> ResultItems
            {
                get
                {
                    if (_resultItems == null)
                        _resultItems = new ObservableCollection<OilSwellResultsItemViewModel>();
                    return _resultItems;
                }
    
                set
                {
                    if (_resultItems != value)
                    {
                        _resultItems = value;
                        this.RaisePropertyChanged("ResultItems");
                    }
                }
            }
    public class OilSwellResultsItemViewModel : NotificationObject
    {
    ...
    private string _rubberType;
    
            public string RubberType
            {
                get { return _rubberType; }
                set
                {
                    if (_rubberType != value)
                    {
                        _rubberType = value;
                        this.RaisePropertyChanged("RubberType");
                    }
                }
            }
    ...
    }

    2:binding wpf control自己的属性

    注意Binding="{Binding Items.Count, ElementName=DataGrid}"的ElementName是指向DataGrid

    <ControlTemplate.Triggers>
                <DataTrigger Binding="{Binding Items.Count, ElementName=DataGrid}" Value="1">
                    <Setter TargetName="OS_Legend" Property="Visibility" Value="Visible" />
                    <Setter TargetName="OSL_Legend" Property="Visibility" Value="Collapsed" />
                    <Setter TargetName="OSLSR_Legend" Property="Visibility" Value="Collapsed" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Items.Count, ElementName=DataGrid}" Value="2">
                    <Setter TargetName="OS_Legend" Property="Visibility" Value="Visible" />
                    <Setter TargetName="OSL_Legend" Property="Visibility" Value="Visible" />
                    <Setter TargetName="OSLSR_Legend" Property="Visibility" Value="Collapsed" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Items.Count, ElementName=DataGrid}" Value="3">
                    <Setter TargetName="OS_Legend" Property="Visibility" Value="Visible" />
                    <Setter TargetName="OSL_Legend" Property="Visibility" Value="Visible" />
                    <Setter TargetName="OSLSR_Legend" Property="Visibility" Value="Visible" />
                </DataTrigger>
            </ControlTemplate.Triggers>
  • 相关阅读:
    关于va_list实例
    va_list、va_start和va_end使用
    react 开发 vscode需要安装的开发插件
    Django(二十)下拉列表-省市联动实例:jquery的ajax处理前端
    Django(二十)分页:
    mysql常用命令
    Mysql8.0免安装包配置方法
    Django(十九)文件上传:图片上传(后台上传、自定义上传)、
    Django(十八)后台管理:列表页选项、编辑页选项、自定义后台页面
    Django(十七):静态文件、中间件
  • 原文地址:https://www.cnblogs.com/shawnzxx/p/3305071.html
Copyright © 2011-2022 走看看