AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-14880014

Gokhan's questions

Martin Hope
Gokhan
Asked: 2024-10-25 15:29:40 +0800 CST

FlowDocument 中的图像布局

  • 5

我在流程文档中添加了一些图像,但所有图片都是按从下到上的顺序列出的。

我想要将图片从左到右按顺序放置,并将内容像换行面板一样在包含框的边缘换行到下一行。

我尝试将图片放入 ListView 和 Wrap Panel 中,但是不起作用。

这是我向流程文档添加图像的方法。

private BlockUIContainer AddImage(BitmapImage bi,double width,double height)
{
    BlockUIContainer blockUI = new BlockUIContainer();
    Image i = new Image();
    i.Source = bi;
    i.Width = width;
    i.Height = height;
    i.HorizontalAlignment = HorizontalAlignment.Left;
    blockUI.Child = i;
    return blockUI;
}

在此处输入图片描述

c#
  • 2 个回答
  • 63 Views
Martin Hope
Gokhan
Asked: 2024-08-07 19:03:32 +0800 CST

将 DataGridCell 内容绑定到自定义 ToolTip WPF 中的文本框

  • 5

我的项目中有数据网格控件,我想向数据网格单元格添加工具提示。我自定义了工具提示控件并在其中放置了一个文本框控件。我尝试将单元格内容值绑定到文本框,但没有成功。

当我直接使用工具提示控制(无需自定义)时,它可以起作用。

这是 xaml 代码:

无需自定义工具提示绑定即可工作。

 <Window.Resources>
            <Style TargetType="{x:Type DataGridCell}">
                <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/>          
            </Style>
</Window.Resources>
     <DataGrid ItemsSource="{Binding Persons}"
               AutoGenerateColumns="True"/>

但自定义的工具提示绑定不起作用。

<Window.Resources>
    <Style TargetType="DataGridCell">
        <Setter Property="ToolTip">
            <Setter.Value>
                <TextBox Text="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/>
            </Setter.Value>
        </Setter>
        
       
    </Style>
</Window.Resources>
     <DataGrid ItemsSource="{Binding Persons}"
               AutoGenerateColumns="True"/>

这是模型类:

public class Person
{
    public string PersonName { get; set; }
    public string Surname { get; set; }
    public string Details { get; set; }
}

这是 ViewModel 类:

public class MainViewVM:INotifyPropertyChanged
{
    public ObservableCollection<Person> Persons { get; set; }
    public MainViewVM()
    {
        Persons = new ObservableCollection<Person>
        {
            new Person()
            {
                PersonName = "Andrei",
                Surname = "Surname 1"

            },

            new Person()
            {
                PersonName = "Jack",
                Surname = "Surname 2"

            },


            new Person()
            {
                PersonName = "Melisa",
                Surname = "Surname 3"

            }
        };
    }
   

    public event PropertyChangedEventHandler PropertyChanged;
    protected void NotifyOfPropertyChange(string name)
    {
        PropertyChangedEventHandler handler = PropertyChanged;

        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(name));
        }
    }

}

在此处输入图片描述

c#
  • 1 个回答
  • 33 Views
Martin Hope
Gokhan
Asked: 2024-02-11 20:00:18 +0800 CST

在 Excel VBA 中创建带条件的汇总表

  • 5

我正在尝试在 Excel 应用程序中使用 VBA 创建汇总表。

为了实现这一点,我将把具有相同文章代码的行减少为一行。为了便于理解,我在下面分享了一张图片。 在此输入图像描述

我试图通过创建一个数组来解决它,但这是一个很长的代码,我无法解决它。

excel
  • 2 个回答
  • 62 Views
Martin Hope
Gokhan
Asked: 2024-01-03 23:11:44 +0800 CST

如何将 Control 的内容属性作为 CommandParameter WPF 传递

  • 5

我的 WPF 项目有 19 个单选按钮。我想设置每个命令属性。为了分隔所有命令操作,我想将RadioButton Content属性作为 CommandParameter 发送。

我尝试为 CommandParameter 属性定义 setter,并设置{Binding Path=Content}Value,如下所示。

但这不是工作。

 <Style TargetType="RadioButton">
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Margin" Value="5"/>
        <Setter Property="Command" Value="{Binding SelectionChangedCommand}"/>
        <Setter Property="CommandParameter" Value="{Binding Path=Content}"/>
    </Style>
          

 <RadioButton Content="Area"/>
            <RadioButton Content="Unit"
                         Grid.Row="1"/>
            
            <RadioButton Content="Transom Count"
                         Grid.Row="2"
                         CommandParameter="Transom Count"/>
            <RadioButton Content="Mullion Count"
                         Grid.Row="3"/>
            <RadioButton Content="Transom And Mulliom Count"
                         Grid.Row="4"/>
            <RadioButton Content="Frame Count"
                         Grid.Row="5"/>
            <RadioButton Content="Frame + Transom + Mullion Count"
                         Grid.Row="6"/>
            <RadioButton Content="Corner Points"
                         Grid.Row="7"/>
            <RadioButton Content="T Connections"
                         Grid.Row="8"/>

            <RadioButton Content="Left"
                         Grid.Column="1"/>
            <RadioButton Content="Right"
                         Grid.Column="1"
                         Grid.Row="1"/>
            <RadioButton Content="Top"
                         Grid.Column="1"
                         Grid.Row="2"/>
            <RadioButton Content="Bottom"
                         Grid.Column="1"
                         Grid.Row="3"/>
            <RadioButton Content="Perimeter"
                         Grid.Column="1"
                         Grid.Row="4"/>
            <RadioButton Content="Transom Length"
                         Grid.Column="1"
                         Grid.Row="5"/>
            <RadioButton Content="Mullion Length"
                         Grid.Column="1"
                         Grid.Row="6"/>
            <RadioButton Content="Transom + Mullion Length"
                         Grid.Column="1"
                         Grid.Row="7"/>
            <RadioButton Content="Perimeter + Transom + Mullion Length"
                         Grid.Column="1"
                         Grid.Row="8"/>

在此输入图像描述

c#
  • 2 个回答
  • 30 Views
Martin Hope
Gokhan
Asked: 2023-11-15 22:21:20 +0800 CST

WPF 中具有 MVVM 模式的画布缩放功能

  • 5

我一直在将我的应用程序转换为 MVVM 模式。我正在尝试找出放大功能。

我的项目中有画布面板和椭圆。

问题是只有当鼠标指针位于形状上时,zoomIn 函数才能工作。

我认为我在 XAML 中创建的画布面板的大小与形状大小相同。所以我需要将此缩放功能应用于画布的父级网格控件。我无法实现这一点。

这些是 XAML 代码。

<Window x:Class="CanvasSampleMvvm.View.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:local="clr-namespace:CanvasSampleMvvm.View"
        xmlns:model="clr-namespace:CanvasSampleMvvm.Model"
        xmlns:vm="clr-namespace:CanvasSampleMvvm.ViewModel"
        mc:Ignorable="d"
        Title="MainView" Height="450" Width="800">

    <Window.Resources>
        <vm:MainViewVM x:Key="vm"/>
    </Window.Resources>
    <Grid DataContext="{StaticResource vm}">

        <ItemsControl ItemsSource="{Binding Path=Shapes}">

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseWheel">
                    <i:InvokeCommandAction Command="{Binding ZoomInCommand}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            
            <ItemsControl.Resources>
                <DataTemplate DataType="{x:Type model:mShape}">
                    <Path Data="{Binding Geometry}" Stroke="{Binding Stroke}" Fill="{Binding Fill}" RenderTransform="{Binding Transform}" />
                </DataTemplate>
            </ItemsControl.Resources>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas DataContext="{StaticResource vm}">
                        <Canvas.RenderTransform>
                            <ScaleTransform
                                ScaleX="{Binding Zoomlevel,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" 
                                ScaleY="{Binding Zoomlevel,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" 
                                CenterX="{Binding ZoomCenterX, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" 
                                CenterY="{Binding ZoomCenterY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        </Canvas.RenderTransform>
                    </Canvas>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style TargetType="ContentPresenter">
                    <Setter Property="Canvas.Left" Value="{Binding Path=XPos}" />
                    <Setter Property="Canvas.Top" Value="{Binding Path=YPos}" />
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>

    </Grid>
</Window>

这些是 ViewModel 代码:

public class MainViewVM : INotifyPropertyChanged
{
    public ObservableCollection<mShape> Shapes { get; } = new ObservableCollection<mShape>();
    private readonly MatrixTransform transform = new MatrixTransform();
    public ZoomInCommand ZoomInCommand { get; set; }
    public MainViewVM()
    {
        ZoomInCommand = new ZoomInCommand(this);

        Shapes.Add(new mShape
        {
            XPos = 100,
            YPos = 100,
            Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x66, 0x66, 0x66)),
            Transform = transform,
            Geometry = new EllipseGeometry { RadiusX = 50, RadiusY = 50 },
            Fill = (SolidColorBrush)new BrushConverter().ConvertFrom("#D3D3D3")

    });
    }
    public void ZoomIn()
    {
        double scaleFactor = zoomLevel;

        Matrix scaleMatrix = Shapes[0].Transform.Matrix;

        scaleMatrix.ScaleAt(scaleFactor, scaleFactor, 0, 0);
        for (int i = 0; i < Shapes.Count; i++)
        {
            double x = Shapes[i].XPos;
            double y = Shapes[i].YPos;
            double sx = x * zoomLevel;
            double sy = y * zoomLevel;
            Shapes[i].XPos = sx;
            Shapes[i].XPos = sy;
            Shapes[i].Transform.Matrix = scaleMatrix;

        }
    }

    private double zoomLevel = 1.1;
    public double ZoomLevel
    {
        get { return zoomLevel; }
        set
        {
            zoomLevel = value;
            OnPropertyChanged("ZoomLevel");
        }
    }

    private double zoomCenterX;
    public double ZoomCenterX
    {
        get { return zoomCenterX; }
        set
        {
            zoomCenterX = value;
            OnPropertyChanged("ZoomCenterX");
        }
    }

    private double zoomCenterY;
    public double ZoomCenterY
    {
        get { return zoomCenterY; }
        set
        {
            zoomCenterY = value;
            OnPropertyChanged("ZoomCenterY");
        }
    }
    private void OnPropertyChanged(string propertyName)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
    public event PropertyChangedEventHandler PropertyChanged;

}

这些是模型类 (mShape)

public class mShape
{
    public double XPos { get; set; }
    public double YPos { get; set; }
    public MatrixTransform Transform { get; set; }
    public Geometry Geometry { get; set; }
    public Brush Stroke { get; set; }
    public Brush Fill { get; set; }
}

这些是 ZoomInCommand 代码:

public class ZoomInCommand : ICommand
{
    event EventHandler ICommand.CanExecuteChanged
    {
        add { CommandManager.RequerySuggested += value; }
        remove { CommandManager.RequerySuggested -= value; }
    }
    public MainViewVM VM { get; set; }
    public ZoomInCommand(MainViewVM vm)
    {
        VM = vm;
    }
    bool ICommand.CanExecute(object parameter)
    {
        return true;
    }
    void ICommand.Execute(object parameter)
    {
        VM.ZoomIn();
    }
}
wpf
  • 1 个回答
  • 25 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve