zoukankan      html  css  js  c++  java
  • 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; }


        }
    }

  • 相关阅读:
    微信网页授权登录(公众号)
    FastDFS:搭建文件管理系统
    第11章 分布式服务跟踪: Spring Cloud Sleuth
    第十章 消息驱动的微服务: Spring Cloud Stream
    第九章 消息总线: Spring Cloud Bus
    第八章 分布式配置中心:Spring Cloud Config
    体验Impress.js
    我擦,惊呆了惊呆了!!!微软这次推了个好东西啊
    化繁为简,无需后端。巧用Yql+rss,搭建我的个人网站
    PuTTY?Bash?Out了!!!终端应该这么玩~
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434615.html
Copyright © 2011-2022 走看看