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>
  • 相关阅读:
    素数筛相关
    ACM-ICPC 2017 Asia Shenyang
    codeforces/contest/1228
    Python 支持的编码格式列表
    Python——json格式数据与字典相互转换
    mysql 数据查询基本语法
    Python 奇葩问题总结;
    Python中的Subprocess模块 python 命令行操作 系统任务管理 执行系统命令
    C++ Json打包数据 查看数据
    mysql数据无法读出 idb文件恢复数据
  • 原文地址:https://www.cnblogs.com/shawnzxx/p/3305071.html
Copyright © 2011-2022 走看看