mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-20 16:36:36 +08:00
项目结构调整
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<Page
|
||||
x:Class="UWP.CartesianChart.DynamicVisibility.DynamicVisibilityExample"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:UWP.CartesianChart.DynamicVisibility"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:lvc="using:LiveCharts.Uwp"
|
||||
xmlns:converters="using:UWP.Converters"
|
||||
xmlns:lvcConverters="using:LiveCharts.Uwp.Converters"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<converters:BoolToObjectConverter x:Key="bvc">
|
||||
<converters:BoolToObjectConverter.TrueValue>
|
||||
<x:Boolean>True</x:Boolean>
|
||||
</converters:BoolToObjectConverter.TrueValue>
|
||||
<converters:BoolToObjectConverter.FalseValue>
|
||||
<x:Boolean>False</x:Boolean>
|
||||
</converters:BoolToObjectConverter.FalseValue>
|
||||
</converters:BoolToObjectConverter>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding MariaSeriesVisibility, Mode=TwoWay}">
|
||||
Maria Series
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding CharlesSeriesVisibility, Mode=TwoWay}">
|
||||
Charles Series
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding JohnSeriesVisibility, Mode=TwoWay}">
|
||||
John Series
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
<lvc:CartesianChart Grid.Row="1" Hoverable="False">
|
||||
<lvc:CartesianChart.Series>
|
||||
<lvc:ColumnSeries Title="Maria" Values="{Binding MariaValues}" Visibility="{Binding MariaSeriesVisibility, Converter={StaticResource bvc}, Mode=OneWay}" MaxWidth="1000" ColumnPadding="0"/>
|
||||
<lvc:ColumnSeries Title="Charles" Values="{Binding CharlesValues}" Visibility="{Binding CharlesSeriesVisibility, Converter={StaticResource bvc}, Mode=OneWay}" MaxWidth="1000" ColumnPadding="0"/>
|
||||
<lvc:ColumnSeries Title="John" Values="{Binding JohnValues}" Visibility="{Binding JohnSeriesVisibility, Converter={StaticResource bvc}, Mode=OneWay}" MaxWidth="1000" ColumnPadding="0"/>
|
||||
</lvc:CartesianChart.Series>
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Labels="{Binding Labels}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="1"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,72 @@
|
||||
using LiveCharts;
|
||||
using System.ComponentModel;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace UWP.CartesianChart.DynamicVisibility
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class DynamicVisibilityExample : Page, INotifyPropertyChanged
|
||||
{
|
||||
private bool _mariaSeriesVisibility;
|
||||
private bool _charlesSeriesVisibility;
|
||||
private bool _johnSeriesVisibility;
|
||||
|
||||
public DynamicVisibilityExample()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MariaSeriesVisibility = true;
|
||||
CharlesSeriesVisibility = true;
|
||||
JohnSeriesVisibility = false;
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public bool MariaSeriesVisibility
|
||||
{
|
||||
get { return _mariaSeriesVisibility; }
|
||||
set
|
||||
{
|
||||
_mariaSeriesVisibility = value;
|
||||
OnPropertyChanged("MariaSeriesVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public bool CharlesSeriesVisibility
|
||||
{
|
||||
get { return _charlesSeriesVisibility; }
|
||||
set
|
||||
{
|
||||
_charlesSeriesVisibility = value;
|
||||
OnPropertyChanged("CharlesSeriesVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public bool JohnSeriesVisibility
|
||||
{
|
||||
get { return _johnSeriesVisibility; }
|
||||
set
|
||||
{
|
||||
_johnSeriesVisibility = value;
|
||||
OnPropertyChanged("JohnSeriesVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public IChartValues MariaValues { get; set; } = new ChartValues<int>(new int[] { 4, 7, 2, 9, 3 });
|
||||
public IChartValues CharlesValues { get; set; } = new ChartValues<int>(new int[] { 6, 2, 6, 3, 8 });
|
||||
public IChartValues JohnValues { get; set; } = new ChartValues<int>(new int[] { 7, 2, 8, 3, 9 });
|
||||
public string[] Labels { get; set; } = new string[] { "January", "February", "March", "April", "May" };
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user