用于平铺列表视图的 WPF 工具包

2023-11-26

我需要创建格式良好的按钮图块,例如 Windows 8 起始页。是否有任何工具包可用于自定义 ListView,它可能支持平铺视图或网格视图,具有一些格式设置,并且可能有一些动画选项。

我尝试创建自己的自定义列表视图,但这似乎是一项复杂的任务。


我不知道有什么好的免费图块控件。开发快递有一个好看的商业版本。

如果您指定了确切的要求(即您需要配置哪些属性,什么样的动画,...)并且我有时间,我会尝试一下。

编辑:我创建了一个 ItemsControl,其中 WrapPanel 作为 ItemsPanel。使用 MVVM 模式,根据您的需求和数据对象扩展控件应该不会太困难。 DragDrop 行为部分很难做到——当然还有一些改进的空间。我没有包含图像。

enter image description here

平铺控件.xaml:

<UserControl x:Class="WpfApplication1.TileControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:local="clr-namespace:WpfApplication1"
             xmlns:beh="clr-namespace:WpfApplication1.Behavior"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.DataContext>
        <local:ViewModel />
    </UserControl.DataContext>

    <UserControl.Resources>
        <local:TileTypeToColorConverter x:Key="TileTypeToColorConverter" />
    </UserControl.Resources>

    <Grid>
        <Image Source="/WpfApplication1;component/Themes/background.png" Stretch="UniformToFill" />
        <Border x:Name="darkenBorder" Background="Black" Opacity="0.6" />
        <ItemsControl ItemsSource="{Binding Tiles}" Background="Transparent" Margin="5">
            <i:Interaction.Behaviors>
                <beh:ItemsControlDragDropBehavior />
            </i:Interaction.Behaviors>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="local:TileModel">
                    <Button Content="{Binding Text}" Background="{Binding TileType, Converter={StaticResource TileTypeToColorConverter}}"
                               Command="{Binding ClickCommand}" Width="120" Height="110" Padding="5" RenderTransformOrigin="0.5, 0.5"  >
                        <Button.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform />
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Button.RenderTransform>
                        <Button.Template>
                            <ControlTemplate TargetType="Button">
                                <Border Padding="5" Background="Transparent">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Border x:Name="tileBackground" Grid.RowSpan="2" Background="{TemplateBinding Background}" Opacity="0.9" />
                                        <Image Source="{Binding Image}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Height="50"  />
                                        <ContentPresenter TextElement.Foreground="White" Grid.Row="1" HorizontalAlignment="Center" Margin="3,10" />
                                    </Grid>
                                </Border>
                            </ControlTemplate>
                        </Button.Template>
                        <Button.Resources>
                            <ElasticEase x:Key="easeOutBounce" EasingMode="EaseOut" Springiness="6" Oscillations="4" />
                        </Button.Resources>
                        <Button.Triggers>
                            <EventTrigger RoutedEvent="Button.Click">
                                <BeginStoryboard>
                                    <Storyboard Duration="00:00:00.05" AutoReverse="True">
                                        <DoubleAnimation To="0.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"/>
                                        <DoubleAnimation To="0.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" From="0.1" To="1.0" EasingFunction="{StaticResource easeOutBounce}" />
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" From="0.1" To="1.0" EasingFunction="{StaticResource easeOutBounce}" />
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.1" To="1.0" EasingFunction="{StaticResource easeOutBounce}" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </Button.Triggers>
                    </Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Grid>
</UserControl>

ViewModel、TileModel、TileType、ActionCommand:

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;
using System.Windows.Media.Imaging;

namespace WpfApplication1
{
    public class ViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        private ObservableCollection<TileModel> _tiles;
        public ObservableCollection<TileModel> Tiles { get { return _tiles; } set { _tiles = value; OnPropertyChanged("Tiles"); } }

        public ViewModel()
        {

           Tiles= new ObservableCollection<TileModel>()
            {
                new TileModel() { Text = "Facebook", Image = Properties.Resources.Facebook.ToBitmapImage(), TileType = TileType.Website },
                new TileModel() { Text = "Skype", Image = Properties.Resources.Skype.ToBitmapImage(), TileType = TileType.Application },
                new TileModel() { Text = "Ask.com", Image = Properties.Resources.AskCom.ToBitmapImage(), TileType = TileType.Website  },
                new TileModel() { Text = "Amazon", Image = Properties.Resources.Amazon.ToBitmapImage(), TileType = TileType.Website },
                new TileModel() { Text = "Evernote", Image = Properties.Resources.Evernote.ToBitmapImage(), TileType = TileType.Application },
                new TileModel() { Text = "Twitter", Image = Properties.Resources.Twitter.ToBitmapImage(), TileType = TileType.Website },
                new TileModel() { Text = "Internet Explorer",  Image = Properties.Resources.InterneExplorer.ToBitmapImage(), TileType = TileType.Browser },
                new TileModel() { Text = "Android", Image = Properties.Resources.Android.ToBitmapImage(), TileType = TileType.Application },
                new TileModel() { Text = "Winamp", Image = Properties.Resources.Winamp.ToBitmapImage(), TileType = TileType.Application },
                new TileModel() { Text = "YouTube", Image = Properties.Resources.YouTube.ToBitmapImage(), TileType = TileType.Website },
            };
        }

    }


    public class TileModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        private string _text;
        public string Text { get { return _text; } set { _text = value; OnPropertyChanged("Text"); } }

        private BitmapSource _image;
        public BitmapSource Image { get { return _image; } set { _image = value; OnPropertyChanged("Image"); } }

        private TileType _tileType;
        public TileType TileType { get { return _tileType; } set { _tileType = value; OnPropertyChanged("TileType"); } }

        public ICommand ClickCommand { get; private set; }

        public TileModel()
        {
            ClickCommand = new ActionCommand(Click);
        }

        private void Click()
        {
            // execute appropriate action
        }

    }

    public enum TileType
    {
        Browser,
        Website,
        Application
    }

    public class ActionCommand : ICommand
    {
        public event EventHandler CanExecuteChanged;
        private Action _action;

        public ActionCommand(Action action)
        {
            _action = action;
        }

        public bool CanExecute(object parameter) { return true; }

        public void Execute(object parameter)
        {
            if (_action != null)
                _action();
        }
    }
}

项目控制拖放行为:

using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interactivity;
using System.Windows.Media;

namespace WpfApplication1.Behavior
{
    public class ItemsControlDragDropBehavior : Behavior<ItemsControl>
    {
        private bool _isMouseDown;
        private bool _isDragging;
        private Point _dragStartPosition;
        private UIElement _dragItem;
        private UIElement _dragContainer;
        private IDataObject _dataObject;
        private int _currentDropIndex;
        private Point _lastCheckPoint;

        protected override void OnAttached()
        {
            this.AssociatedObject.AllowDrop = true;
            this.AssociatedObject.PreviewMouseLeftButtonDown += AssociatedObject_PreviewMouseLeftButtonDown;
            this.AssociatedObject.PreviewMouseMove += AssociatedObject_PreviewMouseMove;
            this.AssociatedObject.PreviewDragOver += AssociatedObject_PreviewDragOver;
            this.AssociatedObject.PreviewDrop += AssociatedObject_PreviewDrop;
            this.AssociatedObject.PreviewMouseLeftButtonUp += AssociatedObject_PreviewMouseLeftButtonUp;

            base.OnAttached();
        }

        void AssociatedObject_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ItemsControl itemsControl = (ItemsControl)sender;
            Point p = e.GetPosition(itemsControl);

            object data = itemsControl.GetDataObjectFromPoint(p);
            _dataObject = data != null ? new DataObject(data.GetType(), data) : null;

            _dragContainer = itemsControl.GetItemContainerFromPoint(p);
            if (_dragContainer != null)
                _dragItem = GetItemFromContainer(_dragContainer);

            if (data != null)
            {
                _isMouseDown = true;
                _dragStartPosition = p;
            }
        }

        void AssociatedObject_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (_isMouseDown)
            {
                ItemsControl itemsControl = (ItemsControl)sender;
                Point currentPosition = e.GetPosition(itemsControl);
                if ((_isDragging == false) && (Math.Abs(currentPosition.X - _dragStartPosition.X) > SystemParameters.MinimumHorizontalDragDistance) ||
                    (Math.Abs(currentPosition.Y - _dragStartPosition.Y) > SystemParameters.MinimumVerticalDragDistance))
                {
                    DragStarted(e.GetPosition(itemsControl));
                }
                e.Handled = true;
            }
        }

        void AssociatedObject_PreviewDragOver(object sender, DragEventArgs e)
        {
            UpdateDropIndex(e.GetPosition(this.AssociatedObject));
        }

        void AssociatedObject_PreviewDrop(object sender, DragEventArgs e)
        {
            UpdateDropIndex(e.GetPosition(this.AssociatedObject));
        }

        void AssociatedObject_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            _isMouseDown = false;
        }

        private void DragStarted(Point p)
        {
            if (!_isDragging)
            {
                _isDragging = true;

                if (_dragContainer != null)
                    _dragContainer.Opacity = 0.3;

                _currentDropIndex = FindDropIndex(p);

                DragDropEffects e = DragDrop.DoDragDrop(this.AssociatedObject, _dataObject, DragDropEffects.Copy | DragDropEffects.Move);

                ResetState();
            }
        }

        private void ResetState()
        {
            if (_dragContainer != null)
                _dragContainer.Opacity = 1.0;

            _isMouseDown = false;
            _isDragging = false;
            _dataObject = null;
            _dragItem = null;
            _dragContainer = null;
            _currentDropIndex = -1;
        }

        private void UpdateDropIndex(Point p)
        {
            if ((_lastCheckPoint - p).Length > SystemParameters.MinimumHorizontalDragDistance) // prevent too frequent call
            {
                int dropIndex = FindDropIndex(p);
                if (dropIndex != _currentDropIndex && dropIndex > -1)
                {
                    this.AssociatedObject.RemoveItem(_dataObject);
                    this.AssociatedObject.AddItem(_dataObject, dropIndex);
                    _currentDropIndex = dropIndex;
                }
                _lastCheckPoint = p;
            }
        }

        private int FindDropIndex(Point p)
        {
            ItemsControl itemsControl = this.AssociatedObject;
            UIElement dropTargetContainer = null;

            dropTargetContainer = itemsControl.GetItemContainerFromPoint(p);

            int index = -1;
            if (dropTargetContainer != null)
            {
                index = itemsControl.ItemContainerGenerator.IndexFromContainer(dropTargetContainer);

                if (!IsPointInTopHalf(p))
                    index = index++; // in second half of item, add after
            }
            else if (IsPointAfterAllItems(itemsControl, p))
            {
                // still within itemscontrol, but after all items
                index = itemsControl.Items.Count - 1;
            }

            return index;
        }

        public bool IsPointInTopHalf(Point p)
        {
            ItemsControl itemsControl = this.AssociatedObject;

            bool isInTopHalf = false;

            UIElement selectedItemContainer = itemsControl.GetItemContainerFromPoint(p);
            Point relativePosition = Mouse.GetPosition(selectedItemContainer);

            if (IsItemControlOrientationHorizontal())
                isInTopHalf = relativePosition.X < ((FrameworkElement)selectedItemContainer).ActualWidth / 2;
            else
                isInTopHalf = relativePosition.Y < ((FrameworkElement)selectedItemContainer).ActualHeight / 2;

            return isInTopHalf;
        }

        private bool IsItemControlOrientationHorizontal()
        {
            bool isHorizontal = false;
            Panel panel = GetItemsPanel();
            if (panel is WrapPanel)
                isHorizontal = ((WrapPanel)panel).Orientation == Orientation.Horizontal;
            else if (panel is StackPanel)
                isHorizontal = ((StackPanel)panel).Orientation == Orientation.Horizontal;

            return isHorizontal;
        }

        private UIElement GetItemFromContainer(UIElement container)
        {
            UIElement item = null;
            if (container != null)
                item = VisualTreeHelper.GetChild(container, 0) as UIElement;
            return item;
        }

        private Panel GetItemsPanel()
        {
            ItemsPresenter itemsPresenter = GetVisualChild<ItemsPresenter>(this.AssociatedObject);
            Panel itemsPanel = VisualTreeHelper.GetChild(itemsPresenter, 0) as Panel;
            return itemsPanel;
        }

        private static T GetVisualChild<T>(DependencyObject parent) where T : Visual
        {
            T child = default(T);

            int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
            for (int i = 0; i < numVisuals; i++)
            {
                Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
                child = v as T;
                if (child == null)
                {
                    child = GetVisualChild<T>(v);
                }
                if (child != null)
                {
                    break;
                }
            }
            return child;
        }

        /// still needs some work
        private static bool IsPointAfterAllItems(ItemsControl itemsControl, Point point)
        {
            bool isAfter = false;

            UIElement target = itemsControl.GetLastItemContainer();
            Point targetPos = target.TransformToAncestor(itemsControl).Transform(new Point(0, 0));
            Point relativeToTarget = new Point(point.X - targetPos.X, point.Y - targetPos.Y);

            if (relativeToTarget.X >= 0 && relativeToTarget.Y >= 0)
            {
                var bounds = VisualTreeHelper.GetDescendantBounds(target);
                isAfter = !bounds.Contains(relativeToTarget);
            }
            return isAfter;
        }
    }

    public static class ItemsControlExtensions
    {
        public static object GetDataObjectFromPoint(this ItemsControl itemsControl, Point p)
        {
            UIElement element = itemsControl.InputHitTest(p) as UIElement;

            while (element != null)
            {
                if (element == itemsControl)
                    return null;

                object data = itemsControl.ItemContainerGenerator.ItemFromContainer(element);
                if (data != DependencyProperty.UnsetValue)
                    return data;
                else
                    element = VisualTreeHelper.GetParent(element) as UIElement;
            }
            return null;
        }

        public static UIElement GetItemContainerFromPoint(this ItemsControl itemsControl, Point p)
        {
            UIElement element = itemsControl.InputHitTest(p) as UIElement;

            while (element != null)
            {
                object data = itemsControl.ItemContainerGenerator.ItemFromContainer(element);

                if (data != DependencyProperty.UnsetValue)
                    return element;
                else
                    element = VisualTreeHelper.GetParent(element) as UIElement;
            }

            return element;
        }

        public static UIElement GetLastItemContainer(this ItemsControl itemsControl)
        {
            UIElement container = null;
            if (itemsControl.HasItems)
                container = itemsControl.GetItemContainerAtIndex(itemsControl.Items.Count - 1);

            return container;
        }

        public static UIElement GetItemContainerAtIndex(this ItemsControl itemsControl, int index)
        {
            UIElement container = null;

            if (itemsControl != null && itemsControl.Items.Count > index && itemsControl.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                container = itemsControl.ItemContainerGenerator.ContainerFromIndex(index) as UIElement;
            else
                container = itemsControl;

            return container;
        }

        public static void AddItem(this ItemsControl itemsControl, IDataObject item, int insertIndex)
        {
            if (itemsControl.ItemsSource != null)
            {
                foreach (string format in item.GetFormats())
                {
                    object data = item.GetData(format);
                    IList iList = itemsControl.ItemsSource as IList;
                    if (iList != null)
                        iList.Insert(insertIndex, data);
                    else
                    {
                        Type type = itemsControl.ItemsSource.GetType();
                        Type genericList = type.GetInterface("IList`1");
                        if (genericList != null)
                            type.GetMethod("Insert").Invoke(itemsControl.ItemsSource, new object[] { insertIndex, data });
                    }
                }
            }
            else
                itemsControl.Items.Insert(insertIndex, item);
        }

        public static void RemoveItem(this ItemsControl itemsControl, IDataObject itemToRemove)
        {
            if (itemToRemove != null)
            {
                foreach (string format in itemToRemove.GetFormats())
                {
                    object data = itemToRemove.GetData(format);
                    int index = itemsControl.Items.IndexOf(data);
                    if (index > -1)
                        itemsControl.RemoveItemAt(index);
                }
            }
        }

        public static void RemoveItemAt(this ItemsControl itemsControl, int removeIndex)
        {
            if (removeIndex != -1 && removeIndex < itemsControl.Items.Count)
            {
                if (itemsControl.ItemsSource != null)
                {
                    IList iList = itemsControl.ItemsSource as IList;
                    if (iList != null)
                    {
                        iList.RemoveAt(removeIndex);
                    }
                    else
                    {
                        Type type = itemsControl.ItemsSource.GetType();
                        Type genericList = type.GetInterface("IList`1");
                        if (genericList != null)
                            type.GetMethod("RemoveAt").Invoke(itemsControl.ItemsSource, new object[] { removeIndex });
                    }
                }
                else
                    itemsControl.Items.RemoveAt(removeIndex);
            }
        }
    }
}

平铺类型到颜色转换器:

public class TileTypeToColorConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        SolidColorBrush brush = new SolidColorBrush();
        TileType type = (TileType)value;
        switch (type)
        {
            case TileType.Browser: brush.Color = Colors.Maroon; break;
            case TileType.Application: brush.Color = Colors.DodgerBlue; break;
            case TileType.Website: brush.Color = Colors.DarkGoldenrod; break;
        }
        return brush;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

用于平铺列表视图的 WPF 工具包 的相关文章

  • 如何更改 TextBox.Text 而不丢失 WPF 中的绑定?

    在 WPF 应用程序中 我正在创建一个设置窗口来自定义键盘快捷键 在文本框中 我处理 KeyDown 事件并将 Key 事件转换为人类可读的形式 以及我想要获取数据的形式 文本框声明如下
  • WPF 模式进度窗口

    如果这个问题已经被回答了很多次 我很抱歉 但我似乎找不到适合我的答案 我想创建一个模式窗口 在我的应用程序执行长时间运行的任务时显示各种进度消息 这些任务在单独的线程上运行 我能够在过程的不同阶段更新进度窗口上的文本 跨线程通信一切正常 问
  • 当其源是 https uri 时如何使 wpf MediaElement 播放

    在 wpf 独立应用程序 exe 中 我在主窗口中包含了 MediaElement
  • 在包含按钮的ListView中,如何获取单击按钮的索引?

    我有一个ListView仅包含按钮 我想做的很简单 我想要获得已单击按钮的索引 列表的计数从0到100不等 因此当用户单击按钮6时 我需要这个数字进行处理 我定义了我的ListView像这样
  • 跨项目/dll 访问 Xaml 中的资源

    是否可以从另一个项目引用存储在 ResourceDictionary 构建操作 资源 中的 Xaml 资源 我想将资产合并到主项目的资源字典中或单独访问它们 例如 项目 MyResources 包含一个名为 Assets 的文件夹 其中有一
  • WPF/数据集:如何通过 XAML 将相关表中的数据绑定到数据网格列中?

    我正在使用 WPF DataSet 连接到 SQL Server Express XAML 和 C Visual Studio 2013 Express 我从名为 BankNoteBook 的现有 SQL Server Express 数据
  • ViewModel 中的 TextBox CaretIndex 属性

    是否可以通过视图中定义的 Binding 获取 设置 wpf 视图模型中 TextBox 控件的 CaretIndex 属性的值 Thanks 这里的问题是如何获得CaretIndex of the TextBox通过视图模型进行控制 如果
  • WPF Datagrid 循环/选择具有特定属性的单元格

    全新的 WPF 对 WinForms 非常熟悉 这可能会让过渡变得更加困难 我正在尝试将旧 WinForms 项目中的一些功能移植到 WPF 中作为学习体验 目标是在 DataGrid 中查找与 TextBox 中的字符串匹配的单元格值 我
  • 当其他列子项折叠时调整 WPF 网格列的大小?

    我有两个控件Grid 并且需要制作一个来填充所有Grid另一个获得后的空间Collapseded 我不知道什么Container我可以使用吗 我试过了StackPanel and DockPanel我也是 但找不到好的解决方案 这是我的代码
  • 绑定导致 StackOverflow

    我不确定我在这里做错了什么 可以说 我有两个用户控件BoxAand BoxB 两者都有一个名为的 DependencyPropertyText BoxB 包装了具有常规 TextBox 的 BoxA 绑定应该像这样 BoxB Text Bo
  • 如何将文本放在 RadioButton 的顶部

    我正在尝试实现附件中显示的效果 但没有成功 甚至有可能吗 我试图将文本框放在单选按钮内 并将其设置为水平和垂直内容对齐 但它没有按我想要的方式工作 欢迎任何建议 Resource
  • 打印大型 WPF 用户控件

    我有一个巨大的数据 我想使用 WPF 打印 我发现WPF提供了一个PrintDialog PrintVisual用于打印派生的任何 WPF 控件的方法Visual class PrintVisual只会打印一页 因此我需要缩放控件以适合页面
  • WPF - 路径几何...有没有办法绑定数据属性?

    我有一个ControlTemplate作为 气泡 弹出窗口AdornerLayer给定的控制 它工作正常 但我需要能够计算它应该显示的位置 中间 底部 代替
  • WPF 还是 WinForms 作为内部工具?

    在我的公司 我们开发了许多内部工具 从简单的实用程序到成熟的编辑器 这些工具的首要任务是稳定性 可用性和周转时间 意味着添加新功能的速度 到目前为止 我们一直在使用 WinForms 但有几个新工具正在酝酿中 我正在权衡是否应该继续使用 W
  • 创建可重用的 WINDOW 控件

    好吧 这似乎很难 或者我错过了一些明显的东西 我想创建可重复使用的 WINDOW 它将在所有产品中使用 这意味着该控件位于 WPF Controls 程序集中 Themes Generic xaml 不是一个解决方案 我需要为窗口提供自己的
  • 依赖属性回调不起作用

    我有以下代码 private static readonly DependencyProperty IDProperty DependencyProperty Register ID typeof int typeof DetailData
  • 如何在控件内引用用户控件主机的 StaticResource?

    我有以下内容StaticResource in my Window Resources
  • 怎么让画笔变得光滑,中间没有线条

    大家好 正如你在之前的画笔中看到的 中间有线条 不太顺利 如何使其平滑 如何删除该行 我用混合创建它
  • WPF:将布尔值显示为“是”/“否”

    我有一个布尔值 需要在 TextBlock 中显示为 是 或 否 我尝试使用 StringFormat 执行此操作 但我的 StringFormat 被忽略并且 TextBlock 显示 True 或 False
  • MVVM 消息传递或事件或其他什么选项?

    我在 MainViewModel 中有一个菜单 现在在选择特定的菜单项时我想更新已加载的视图的数据 即 虽然 MainViewModel 中有该 viewModel 的实例 但当我尝试通过该实例调用该方法并更改数据属性时 它不会显示视图中的

随机推荐

  • 当块位于初始值设定项中时捕获块中的变量

    考虑一下 id observer NSNotificationCenter defaultCenter addObserverForName MyNotification object nil queue nil usingBlock NS
  • 正则表达式模式用于检查字符串中每个单词的第一个字母在 Javascript 中是否为大写

    例如我的字符串是Foo Bar 该字符串应该与模式匹配 如果字符串是Foo bar 该字符串不应匹配 如果字符串是福巴 福巴字符串应该匹配 如果字符串是Foo 它也应该匹配 到目前为止我只有这个模式 A Z 1 s 基本上我只会接受每个单词
  • WPF:如何通过 XAML 将整个 Control 作为 CommandParameter 传递?

    我正在使用 MVVM 自定义 ICommand 对象由 ViewModel 层提供 一个 ViewModel 对象可以同时通过 DataContext 属性附加到许多 View 对象 窗口 页面等 在 ICommand CanExecute
  • SqlDependency 与 EntityFramework 6(异步)

    我正在使用 EF 6async查询特征 例如 var list await cx Clients Where c gt c FirstName Length gt 0 ToListAsync 我还想启动对这些查询的 SQL 依赖项 以便在数
  • 如何更改 WCF 中的 SOAP 信封架构?

    我正在通过 WCF 连接到第三方端点 但遇到一个问题 WCF 生成的 SOAP 信封架构与端点不兼容 目前 WCF 正在生成
  • 滚动到特定 div

    我有几个divs posts其中有一个attr data id这对应于mysql DB id div class posts div div class posts div 现在如果我想滚动到特定的div只有我知道data id 我将如何滚
  • RX Observable.TakeWhile 检查每个元素之前的条件,但我需要在之后执行检查

    Observable TakeWhile 允许您在条件为真时运行序列 使用委托 以便我们可以对实际序列对象执行计算 但它会在每个元素之前检查此条件 如何在每个元素之后执行相同的检查 下面的代码演示了这个问题 void RunIt List
  • 将字符集转换为 nfa/dfa 的高效算法

    我目前正在研究扫描仪生成器 发电机已经工作正常 但是当使用字符类时 算法会变得非常慢 扫描仪生成器生成 UTF8 编码文件的扫描仪 应支持完整范围的字符 0x000000 到 0x10ffff 如果我使用大字符集 例如任何运算符 或 uni
  • iframe 内容在 Firefox 上消失

    我正在用基本的 HTML 填充一个空的 iframe 使用 iframe contents find body html contentBody See http jsfiddle net UjT2b 2 这在 Chrome 上效果很好 在
  • Mapbox gl js - 重叠图层和鼠标事件处理

    是否有任何清晰可靠 和描述 的机制来控制 Mapbox GL JS 中重叠图层的鼠标事件 例如 我有 3 个重叠的层 但希望仅对顶部的层调用单击处理程序 而不是对所有 3 个层调用 这是否可能 目前 作为解决方法 我跟踪 MouseEnte
  • Jpgraph 不会改变我的条形图上的颜色

    我刚刚开始使用 jpgraph 和 XAMPP 我想制作一个条形图 当我在网上阅读一些文章时 它说您可以传递一系列颜色来设置填充颜色 以便每个条形都具有不同的颜色 然而 每当我传递它的颜色时 图表都不会改变其默认的浅蓝色颜色 图表响应数据的
  • 扩展 prestashop web 服务资源

    我正在尝试延长carts多一个字段的资源应输出以下结果Cart getSummaryDetails称呼 我已经延长了CartCore类添加新参数和相应的方法 如下所示 class Cart extends CartCore protecte
  • MS Access 通过文本框而不是下拉列表搜索记录

    我对 MS Access 还很陌生 我正在尝试创建一个简单的表单 基本上将使用文本框而不是下拉框搜索特定记录 本质上 用户将能够输入 ID 号并检索一些其他相关信息 但是 我不希望用户能够向数据库添加任何新记录 我已经能够让表单看起来像我想
  • 使用 Javascript 转到本地 URL

    同样的问题here但我需要在 Firefox 中访问本地 URL 我尝试使用类似的代码 var url file E Test Test htm window location href url 但 id 不起作用 尝试去与window l
  • PHP PDO 缓存

    我一直在寻找这个问题的答案 但没有在任何地方找到 对 PDO prepare 的调用是否已缓存 或者我应该自己缓存结果 即如果我执行以下操作 function foo handle PDO prepare do stuff with the
  • SQL Server ORDER BY 日期和最后的空值

    我正在尝试按日期订购 我希望最近的日期排在最前面 这很简单 但是有许多记录为空 并且这些记录位于任何具有日期的记录之前 我尝试了一些方法但没有成功 ORDER BY ISNULL Next Contact Date 0 ORDER BY I
  • 更改 PreferenceActivity 文本颜色

    我想将 Android 应用程序的首选项屏幕的外观更改为深色文本颜色 我怎样才能做到这一点 我已经将背景更改为白色 我假设您使用一个 Activity 来扩展PreferenceActivity 您可以使用setTheme方法在您的首选项屏
  • 使用 web.config 允许服务器端包含在 HTML 文件中 (IIS)

    在IIS 7 5中 是否可以使用网络配置单独启用SSI处理具有以下内容的文件 html扩大 具体来说 我不想使用默认的 SSI 扩展 shtml Reason 我不想更改扩展名 这样做会导致搜索引擎结果中的链接损坏 另外 我这样做的动机是网
  • asp.net core 2.0中的机器密钥?

    我有相同的 asp net core 2 应用程序在 2 个不同的服务器上运行 但使用相同的数据库来存储用户等 问题是 如果我在一台服务器中创建并设置用户密码 则运行同一应用程序的另一台服务器将返回无效密码 反之亦然 几年前 我在使用 AS
  • 用于平铺列表视图的 WPF 工具包

    我需要创建格式良好的按钮图块 例如 Windows 8 起始页 是否有任何工具包可用于自定义 ListView 它可能支持平铺视图或网格视图 具有一些格式设置 并且可能有一些动画选项 我尝试创建自己的自定义列表视图 但这似乎是一项复杂的任务