1 Star 0 Fork 25

DoD / WPFDevelopers.Minimal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Welcome to WPFDevelopers.Minimal

.net >= 4.0 Visual Studio 2019 nuget-version WPF开发者

自定义高级控件 https://github.com/WPFDevelopersOrg/WPFDevelopers

码云 https://gitee.com/WPFDevelopersOrg

欢迎关注微信公众号

捐助

如果您觉得我们的开源软件对你有所帮助,请扫下方二维码打赏我们一杯咖啡。

支付宝 微信

.Net Version

.Net Version Status
Net40
net45
net46
net47
net48
netcoreapp3.0
net5.0-windows

效果展示

0

第一步: 添加 nuget;

Install-Package WPFDevelopers.Minimal

第二步: App.xaml中增加节点:

           <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Theme.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

第三步:添加命名空间:

xmlns:ws="https://github.com/WPFDevelopersOrg.WPFDevelopers.Minimal"

如何方法

数据源
Window
MessageBox
Menu|ContextMenu
Button
RadioButton
Checkbox
TextBox
PasswordBox
ComboBox
ToggleButton
DatePicker
Slider
ProgressBar
DataGrid
ListBox
ListView
TreeView
Expander
GroupBox
TabControl

数据源

1)数据源

using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using WPFDevelopers.Minimal.Sample.Models;

namespace WPFDevelopers.Minimal.Sample.ExampleViews
{
    public partial class MainView : WPFDevelopers.Minimal.Net40.Window
    {
        #region DataSource
        public ObservableCollection<UserModel> UserCollection
        {
            get { return (ObservableCollection<UserModel>)GetValue(UserCollectionProperty); }
            set { SetValue(UserCollectionProperty, value); }
        }

        public static readonly DependencyProperty UserCollectionProperty =
            DependencyProperty.Register("UserCollection", typeof(ObservableCollection<UserModel>), typeof(MainView), new PropertyMetadata(null));


        public bool AllSelected
        {
            get { return (bool)GetValue(AllSelectedProperty); }
            set { SetValue(AllSelectedProperty, value); }
        }

        public static readonly DependencyProperty AllSelectedProperty =
            DependencyProperty.Register("AllSelected", typeof(bool), typeof(MainView), new PropertyMetadata(AllSelectedChangedCallback));

        private static void AllSelectedChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var view = d as MainView;
            var isChecked = (bool)e.NewValue;
            if ((bool)e.NewValue)
                view.UserCollection.ToList().ForEach(y => y.IsChecked = isChecked);
            else
                view.UserCollection.ToList().ForEach(y => y.IsChecked = isChecked);
        }

        #endregion

        public MainView()
        {
            InitializeComponent();
            this.Loaded += MainView_Loaded;
        }

        private void MainView_Loaded(object sender, RoutedEventArgs e)
        {
            var time = DateTime.Now;
            UserCollection = new ObservableCollection<UserModel>();
            for (int i = 0; i < 4; i++)
            {
                UserCollection.Add(new UserModel
                {
                    Date = time,
                    Name = "WPFDevelopers",
                    Address = "No. 189, Grove St, Los Angeles",
                    Children = new System.Collections.Generic.List<UserModel>()
                    {
                         new UserModel { Name= "WPFDevelopers.Minimal1.1" },
                         new UserModel { Name = "WPFDevelopers.Minimal1.2" },
                         new UserModel { Name = "WPFDevelopers.Minimal1.3" },
                          new UserModel { Name= "WPFDevelopers.Minimal1.4" },
                         new UserModel { Name = "WPFDevelopers.Minimal1.5" },
                         new UserModel { Name = "WPFDevelopers.Minimal1.6" },
                    }
                });
                time = time.AddDays(2);
            }
        }
    }
}

Window

1)XAML

ws:Window x:Class="WpfApp.MainWindow"

2)去除.cs文件中的继承

public partial class MainWindow 

Window

MessageBox

1).cs 使用如下

WPFDevelopers.Minimal.Controls.MessageBox.Show("文件删除成功。", "消息",MessageBoxButton.OK,MessageBoxImage.Information);
WPFDevelopers.Minimal.Controls.MessageBox.Show("当前文件不存在!", "警告", MessageBoxImage.Warning);
WPFDevelopers.Minimal.Controls.MessageBox.Show("当前文件不存在。", "错误", MessageBoxImage.Error);
WPFDevelopers.Minimal.Controls.MessageBox.Show("当前文件不存在,是否继续?", "询问", MessageBoxButton.OKCancel, MessageBoxImage.Question);

MessageBox

Menu|ContextMenu

1)XAML

 <WrapPanel Margin="0,10">
                    <WrapPanel.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="1323"/>
                        </ContextMenu>
                    </WrapPanel.ContextMenu>
                    <Menu>
                        <MenuItem Header="MenuItem 1">
                            <MenuItem Header="MenuItem 1.1">
                                <MenuItem Header="MenuItem 1.1.1"/>
                                <MenuItem Header="MenuItem 1.1.2"/>
                            </MenuItem>
                            <Separator/>
                            <MenuItem Header="MenuItem 1.2"/>
                            <MenuItem Header="MenuItem 1.3"/>
                            <MenuItem Header="MenuItem 1.4"/>
                            <MenuItem Header="MenuItem 1.5"/>
                        </MenuItem>
                        <MenuItem Header="MenuItem 2"/>
                        <MenuItem Header="MenuItem 3"/>
                        <MenuItem Header="MenuItem 4"/>
                    </Menu>
</WrapPanel>
                

Menu

Button

1)XAML

 <WrapPanel Margin="0,10">
                    <Button Content="Default"/>
                    <Button Content="Default" Margin="10,0" IsEnabled="False"/>
                    <Button Content="Primary" Style="{StaticResource PrimaryButton}"/>
                    <Button Content="Primary" Style="{StaticResource PrimaryButton}" Margin="10,0" IsEnabled="False"/>
 </WrapPanel>

Button

RadioButton

1)XAML

 <WrapPanel Margin="0,10">
                   <RadioButton Content="Option A"/>
                    <RadioButton Content="Option B" Margin="10,0" IsChecked="True"/>
                    <RadioButton Content="Option C" IsEnabled="False"/>
 </WrapPanel>

RadioButton

Checkbox

1)XAML

 <WrapPanel Margin="0,10">
                 <CheckBox Content="Option A"/>
                 <CheckBox Content="Option B" Margin="10,0" IsChecked="True"/>
                 <CheckBox Content="Option C" IsChecked="{x:Null}"/>
                 <CheckBox Content="Option D" Margin="10,0" IsEnabled="False"/>
 </WrapPanel>

Checkbox

TextBox

1)XAML

 <WrapPanel Margin="0,10">
                  <TextBox/>
                    <TextBox Margin="10,0" ws:ElementHelper.Watermark="请输入内容"/>
                    <TextBox IsEnabled="False"/>
 </WrapPanel>

TextBox

PasswordBox

1)XAML

 <WrapPanel Margin="0,10">
                <PasswordBox />
                    <PasswordBox Margin="10,0" ws:ElementHelper.Watermark="请输入密码"/>
                    <PasswordBox IsEnabled="False"/>
 </WrapPanel>

PasswordBox

ComboBox

1)XAML

 <WrapPanel Margin="0,10">
              <ComboBox Width="200">
                        <ComboBoxItem>Option 1</ComboBoxItem>
                        <ComboBoxItem>Option 2</ComboBoxItem>
                        <ComboBoxItem>Option 3</ComboBoxItem>
                        <ComboBoxItem>Option 4</ComboBoxItem>
                        <ComboBoxItem>Option 5</ComboBoxItem>
                    </ComboBox>
 </WrapPanel>

ComboBox

ToggleButton

1)XAML

 <WrapPanel Margin="0,10">
           <ToggleButton/>
                    <ToggleButton Margin="10,0" IsEnabled="False"/>
                    <ToggleButton IsChecked="True"/>
 </WrapPanel>

ToggleButton

DatePicker

1)XAML

 <WrapPanel Margin="0,10">
           <DatePicker Width="200"/>
                    <DatePicker Width="200" SelectedDateFormat="Long" Margin="10,0"/>
                    <DatePicker Width="200" IsEnabled="False"/>
 </WrapPanel>

DatePicker

Slider

1)XAML

 <WrapPanel Margin="0,10">
           <Slider Width="200"/>
                    <Slider Width="200" Value="50" Maximum="100"  Margin="10,0"/>
                    <Slider Width="200" Value="50" Maximum="100" IsEnabled="False"/>
 </WrapPanel>

Slider

ProgressBar

1)XAML

 <WrapPanel Margin="0,10">
         <ProgressBar Width="200" Value="50" />
                    <ProgressBar Width="200" Margin="10,0"  Value="80" />
                    <ProgressBar Width="200" Margin="10,0" Height="10" IsIndeterminate="True" Value="10"/>
 </WrapPanel>

ProgressBar

DataGrid

1)XAML Mode 1

 <WrapPanel Margin="0,10">
          <DataGrid AutoGenerateColumns="False" HeadersVisibility="All" RowHeaderWidth="40"
                                  ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}"
                                  Margin="0,10">
                            <DataGrid.RowHeaderTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="{Binding IsSelected,RelativeSource={RelativeSource AncestorType=DataGridRow}}"/>
                                </DataTemplate>
                            </DataGrid.RowHeaderTemplate>
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Date" Binding="{Binding Date}" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Address" Binding="{Binding Address}" IsReadOnly="True"/>
                            </DataGrid.Columns>
                        </DataGrid>
 </WrapPanel>

2)XAML Mode 2

 <WrapPanel Margin="0,10">
        <DataGrid AutoGenerateColumns="False" 
                                  ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}"
                                  Margin="0,10">
                            <DataGrid.Columns>
                                <DataGridTemplateColumn CanUserResize="False">
                                <DataGridTemplateColumn.HeaderTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MainView}, Path=AllSelected}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.HeaderTemplate>
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding IsChecked}"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                                <DataGridTextColumn Header="Date" Binding="{Binding Date}" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Address" Binding="{Binding Address}" IsReadOnly="True"/>
                            </DataGrid.Columns>
                        </DataGrid>
 </WrapPanel>

DataGrid

ListBox

1)XAML

 <WrapPanel Margin="0,10">
        <ListBox DisplayMemberPath="Name" IsEnabled="False"
                        ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}">
                    </ListBox>
                    <ListBox  Margin="10,0"
                             ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <UniformGrid Columns="3">
                                    <TextBlock Text="{Binding Date}"/>
                                    <TextBlock Text="{Binding Name}"/>
                                    <TextBlock Text="{Binding Address}"/>
                                </UniformGrid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
 </WrapPanel>

ListBox

ListView

1)XAML

 <WrapPanel Margin="0,10">
       <ListView ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Date" DisplayMemberBinding="{Binding Date}" />
                                <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
                                <GridViewColumn Header="Address" DisplayMemberBinding="{Binding Address}" Width="Auto"/>
                            </GridView>
                        </ListView.View>
                    </ListView>
                    <ListView IsEnabled="False" Margin="10,0" BorderThickness="0"
                              ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Date" DisplayMemberBinding="{Binding Date}" />
                                <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
                                <GridViewColumn Header="Address" DisplayMemberBinding="{Binding Address}" Width="Auto"/>
                            </GridView>
                        </ListView.View>
                    </ListView>
 </WrapPanel>

ListView

TreeView

1)XAML

 <WrapPanel Margin="0,10">
       <TreeView ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}">
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                <Border>
                                    <TextBlock Text="{Binding Path=Name}"/>
                                </Border>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>
                    <TreeView IsEnabled="False" Margin="10,0" BorderThickness="0"
                              ItemsSource="{Binding UserCollection,RelativeSource={RelativeSource AncestorType=local:MainView}}">
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                <Border>
                                    <TextBlock Text="{Binding Path=Name}"/>
                                </Border>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>
 </WrapPanel>

TreeView

Expander

1)XAML

 <WrapPanel Margin="0,10">
       <Expander Header="Expander1">
                        <Rectangle Fill="{DynamicResource DangerSolidColorBrush}"
                                   Width="400" Height="300"/>
                    </Expander>
                    <Expander Header="Expander1" Margin="10,0" FlowDirection="RightToLeft" IsExpanded="True">
                        <Rectangle Fill="{DynamicResource LightSolidColorBrush}"
                                   Width="400" Height="300"/>
                    </Expander>
 </WrapPanel>

Expander

GroupBox

1)XAML

 <WrapPanel Margin="0,10">
      <GroupBox Header="GroupBox1">
                        <Rectangle Fill="{DynamicResource DangerSolidColorBrush}"
                                   Width="400" Height="300"/>
                    </GroupBox>
                    <GroupBox Header="GroupBox1" Margin="10,0" IsEnabled="False">
                        <Rectangle Fill="{DynamicResource LightSolidColorBrush}"
                                   Width="400" Height="300"/>
                    </GroupBox>
 </WrapPanel>

GroupBox

TabControl

1)XAML

  <UniformGrid Columns="2" Rows="2" Margin="0,10">
                    <UniformGrid.Resources>
                        <Style TargetType="{x:Type Rectangle}">
                            <Setter Property="Width" Value="{x:Static SystemParameters.PrimaryScreenWidth}"/>
                            <Setter Property="Height" Value="400"/>
                        </Style>
                    </UniformGrid.Resources>
                    <TabControl>
                        <TabItem Header="TabItem1">
                            <Rectangle Fill="{DynamicResource DangerSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem2">
                            <Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem3" >
                            <Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/>
                        </TabItem>
                    </TabControl>
                    <TabControl TabStripPlacement="Bottom">
                        <TabItem Header="TabItem1">
                            <Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem2">
                            <Rectangle Fill="{DynamicResource DangerSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem3" >
                            <Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/>
                        </TabItem>
                    </TabControl>
                    <TabControl TabStripPlacement="Left">
                        <TabItem Header="TabItem1">
                            <Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem2">
                            <Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem3" >
                            <Rectangle Fill="{DynamicResource DangerSolidColorBrush}"/>
                        </TabItem>
                    </TabControl>
                    <TabControl TabStripPlacement="Right" IsEnabled="False">
                        <TabItem Header="TabItem1">
                            <Rectangle Fill="{DynamicResource SuccessSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem2">
                            <Rectangle Fill="{DynamicResource InfoSolidColorBrush}"/>
                        </TabItem>
                        <TabItem Header="TabItem3" >
                            <Rectangle Fill="{DynamicResource WarningSolidColorBrush}"/>
                        </TabItem>
                    </TabControl>
                </UniformGrid>

TabControl

2
3
4
5
6
7
8
9

MIT License Copyright (c) 2022 WPFDevelopersOrg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

这是一款WPF基础控件,欢迎使用 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/dcxin/WPFDevelopers.Minimal.git
git@gitee.com:dcxin/WPFDevelopers.Minimal.git
dcxin
WPFDevelopers.Minimal
WPFDevelopers.Minimal
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891