小编use*_*902的帖子

如何将WPF DataGrid绑定到ObservableCollection

你能给我一个如何将WPF DataGrid绑定到ObservableCollection的技巧吗?我看过一些帖子并没有找到直接答案.这里和任何地方都有错综复杂的问题,但我的问题并不复杂.我有一个可观察的集合和WPF DataGrid.它们都在WPF应用程序中,它是双工合同WCF服务的客户端.这是一个ObservableCollection:

private ObservableCollection<MyClass> _myCollection = new ObservableCollection<MyClass>();
public ObservableCollection<MyClass> DownloadsCollection
{
    get { return this._downloadsCollection; }
}
Run Code Online (Sandbox Code Playgroud)

这是DataGrid的XAML标记:

<Window x:Class="DownloadManager_Client.MainWindow"
. . . . . . . .>

    <DataGrid Name="dgDownloadsInfo" Grid.Row="2" Grid.Column="0" AutoGenerateColumns="False" CanUserAddRows="False"
              CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False"
              CanUserResizeRows="False" CanUserSortColumns="False" SelectionMode="Single" SelectionChanged="dgDownloadsInfo_SelectionChanged">
          <DataGrid.Columns>
                <DataGridTextColumn Header="DownloadId" Visibility="Hidden"/>
                <DataGridTextColumn Header="Target URL" FontFamily="Arial" />
                <DataGridTextColumn Header="Content Size" FontFamily="Arial"/>
                <DataGridTextColumn Header="Path to Save" FontFamily="Arial"/>
                <DataGridTextColumn Header="Bytes Downloaded" FontFamily="Arial"/>
                <DataGridTextColumn Header="Percent (%)" FontFamily="Arial"/>
                <DataGridTextColumn Header="Status" FontFamily="Arial"/>
          </DataGrid.Columns>
    </DataGrid>
. . . . . . …
Run Code Online (Sandbox Code Playgroud)

c# wpf wcf

7
推荐指数
2
解决办法
4万
查看次数

如何检查字符串在非托管C++代码中是否具有有效的文件路径或目录路径格式?

我想知道如何检查(在非托管的Visual C++代码中)字符串是否具有表示文件路径或文件夹路径的有效格式.在这种情况下,物理文件或文件夹路径本身可能存在也可能不存在.在我的情况下,检查正确的字符串格式是主要目标.我需要知道一个字符串是否具有正确的格式作为有效的文件路径或它没有?C#有很多关于它的帖子,但没有一个关于非托管C++的帖子.如何在Visual C++中的非托管C++中执行此操作?

c++ string-formatting filepath

5
推荐指数
1
解决办法
2万
查看次数

如何在 WPF MVVM Catel 应用程序中切换多个视图?

在 MS VS 2015 Professional 中,我使用 Catel 作为 MVVM 框架开发了 C# WPF MVVM 应用程序。我的问题是我不知道如何使用按钮在一个窗口中实现多个视图之间的切换。下面我简单介绍一下我的应用。MainWindow 有三个按钮

<catel:Window x:Class="FlowmeterConfigurator.Views.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:catel="http://catel.codeplex.com"
          ResizeMode="CanResize">

     <catel:StackGrid x:Name="LayoutRoot">
        <catel:StackGrid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
        </catel:StackGrid.RowDefinitions>

        <ToolBar>
            <Button Name="btnConnectDisconnect" Content="Connect/Disconnect"/>
            <Button Name="btnFieldSettings" Content="Field Settings"/>
            <Button Name="btnCalibration" Content="Flowmeter Calibration"/>
        </ToolBar>
    </catel:StackGrid>
</catel:Window>
Run Code Online (Sandbox Code Playgroud)

应用程序 MainWindow 有一个 ViewModel。为简洁起见,我不在这里展示。除了 MainWindow 之外,我的应用程序中还有三个视图:ConnectDisconnectView、CalibrationView 和 FieldSettingsView。为简洁起见,我在此仅显示其中一个 (FieldSettingsView),因为所有其他人都是在 catel:UserControl 的基础上以相同方式创建的。

<catel:UserControl x:Class="FlowmeterConfigurator.Views.FieldSettingsView"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:catel="http://catel.codeplex.com">

    <catel:StackGrid>
        <catel:StackGrid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </catel:StackGrid.RowDefinitions>
        <catel:StackGrid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </catel:StackGrid.ColumnDefinitions>

        <Label Grid.Row="0" Grid.Column="0" …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm catel

2
推荐指数
1
解决办法
1211
查看次数

当我运行WPF MVVM应用程序时,会显示两个主窗口实例

我在MS VS 2015 Professional(.NET Framework 4.6)中开发WPF MVVM应用程序.当我运行我的WPF MVVM应用程序时,我的应用程序主窗口的两个实例正在显示.它为什么有位置?下面是我的应用程序主窗口的标记 - MainWindow.xaml:

<Window x:Class="SuperMrgaChartDrawer.MainWindow"
       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:local="clr-namespace:SuperMrgaChartDrawer"
       xmlns:vm="clr-namespace:SuperMrgaChartDrawer.ViewModel"
       mc:Ignorable="d"
       Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

下面是MainWindow.xaml.cs的代码:

using System.Windows;

namespace SuperMrgaChartDrawer
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是App.xaml.cs的代码:

using System;
using System.Windows;
using SuperMrgaChartDrawer.ViewModel;

namespace SuperMrgaChartDrawer
{
    public partial class App : Application
    {
        /// <summary>
        /// My application OnStartup handler.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        { …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf mvvm

1
推荐指数
1
解决办法
362
查看次数

标签 统计

c# ×3

wpf ×3

mvvm ×2

.net ×1

c++ ×1

catel ×1

filepath ×1

string-formatting ×1

wcf ×1