• WPF 柱状图显示数据


    <Window x:Class="Wpf180706.Window9"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window9" Height="300" Width="300">
        <Grid>
            <ListBox Name="listBox">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Rectangle Fill="Gray" Width="{Binding Price}"></Rectangle>
                            <TextBlock Text="{Binding Year}"></TextBlock>
                            <TextBlock Text="{Binding Price}" Grid.Column="1"></TextBlock>
                        </Grid>
                        
                    </DataTemplate>

                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

    </Window>


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;


    namespace Wpf180706
    {
        /// <summary>
        /// Interaction logic for Window9.xaml
        /// </summary>
        public partial class Window9 : Window
        {
            public Window9()
            {
                InitializeComponent();
                listBox.ItemsSource = lst;
            }


            public List<MyClass> lst = new List<MyClass>()
            {
                new MyClass(){ Price=120, Year=1990},
                new MyClass(){ Price=50, Year=1950},
                new MyClass(){ Price=220, Year=1998},
                new MyClass(){ Price=150, Year=1992},
                new MyClass(){ Price=100, Year=1991},
                new MyClass(){ Price=190, Year=1999}
            };
            




        }


        public class MyClass
        {
            public int Price { get; set; }
            public int Year { get; set; }


        }
    }

  • 相关阅读:
    ABAP POH和POV事件中 获得屏幕字段的值
    SAP 发送邮件 面向对象
    SAP文件的上传下载 SMW0,二进制文件
    SAP smartform 实现打印条形码
    SAP GB01替代 程序:RGUGBR00
    SAP问题【转载】
    物料库存确定组
    SAP ECC EHP7 RFC 发布成WebService
    NUMBER_GET_NEXT 获取编号 遇到关于按年度编号的问题
    SAP 参照sto订单创建外向交货BAPI
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434615.html
Copyright © 2020-2023  润新知