首页 > 其他分享 >WPF master detail view

WPF master detail view

时间:2024-06-08 20:21:43浏览次数:15  
标签:Windows Media detail System master using WPF MainWindow

<Window x:Class="WpfApp143.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:WpfApp143"
        mc:Ignorable="d" WindowState="Maximized"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <ListBox Grid.Column="0"  ItemsSource="{Binding}" FontSize="16"
                 DisplayMemberPath="ProcessName" x:Name="_master"/>
        <Grid Grid.Column="1" TextBlock.FontSize="16" DataContext="{Binding SelectedItem,ElementName=_master}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <TextBlock Foreground="Red" Margin="6" Text="{Binding ProcessName,StringFormat='Name:\{0\}'}"/>
            <TextBlock Foreground="Green" Grid.Row="1" Margin="6" Text="{Binding Id,StringFormat='ID:0'}"/>
            <TextBlock Foreground="Blue" Grid.Row="2" Margin="6" Text="{Binding PriorityClass,StringFormat='Priority Class:\{0\}'}"/>
            <TextBlock Foreground="Orange" Grid.Row="3" Margin="6" Text="{Binding Threads.Count,StringFormat='Threads:0'}"/>
            <TextBlock Foreground="Cyan" Grid.Row="4" Margin="6" Text="{Binding TotalProcessorTime,StringFormat='Processor Time:\{0:G\}'}"/>
        </Grid>
    </Grid>
</Window>


//cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp143
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = Process.GetProcesses().OrderBy(x=>x.ProcessName);
        }
    }
}

 

 

 

 

<Grid Grid.Column="1" TextBlock.FontSize="16" DataContext="{Binding SelectedItem,ElementName=_master}">
</Grid>

 

标签:Windows,Media,detail,System,master,using,WPF,MainWindow
From: https://www.cnblogs.com/Fred1987/p/18238913

相关文章

  • Preview failedUnable to start the previewer. openPreviewerLog to check for detai
    DevEcostudio预览器报错 PreviewfailedUnabletostartthepreviewer.openPreviewerLogtocheckfordetails.有两种原因1.main_page.json     src下的路径是否重复        2.struct关键字声明自定义组件名称是否重复我自己排查出来的......
  • 同星TSMaster中如何自定义E2E校验算法
    文章目录前言一、自定义E2E算法教程1.定义checksum算法2.定义【CAN预发送事件】3.E2E报文信号仿真4.运行工程二、TSMaster配置E2E教程1.激活仿真报文2.E2E配置三.小结前言最近因项目需要,用到TSMaster进行E2E校验算法实现。第一次使用TSMaster,把整个的过程做一个记......
  • WPF RepeatButton
    是一个特殊的按钮,用于在用户长按或连续点击时重复执行特定动作。它通常用于需要重复执行某个操作的场景。常用属性描述Delay用于获取或设置RepeatButton在开始重复之前被按下时等待的时间(以毫秒为单位)。该值必须为非负数。Interval用于获取或设置开始重复后重复之......
  • WPF button mouseover background change color
    <Applicationx:Class="WpfApp142.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-nam......
  • 在WPF程序中如何实现主题,字体的切换
    在wpf程序中如何实现主题变换,首先我们需要先思考主题切换都更改了一些什么,无非就是字体颜色,背景颜色等一些资源当我们了解了主题变换的本质后就能够进一步去实现它,众所周知,在wpf中我们可以通过资源绑定的形式去实现颜色,字体,样式等一些资源绑定,在wpf中如果有相同的key通常会绑......
  • 【WPF】Dispatcher 与消息循环
    这一期的话题有点深奥,不过按照老周一向的作风,尽量讲一些人鬼都能懂的知识。咱们先来整个小活开开胃,这个小活其实老周在N年前写过水文的,常阅读老周水文的伙伴可能还记得。通常,咱们按照正常思路构建的应用程序,第一个启动的线程为主线程,而且还是UI线程(当然,WPF默认会创建辅助线......
  • WPF grid column resize via GridSpitter, when you can drag to enlarge or shrink t
    <Windowx:Class="WpfApp137.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft......
  • Master ABP Framework(熟练掌握 ABP 框架)
    前言ABP框架是一个完整的基础框架,用于通过遵循软件开发的最佳实践和惯例来创建现代Web应用程序。ABP提供了一个高级框架和生态系统,以帮助您实施“不要重复自己”(DRY)原则并专注于您的业务代码。本书由ABP框架的创建者撰写,将帮助您从头开始全面了解ABP框架和现代Web应用程序开发......
  • WPF,图表控件
    开源代码地址:https://github.com/bearhanQ/WPFFramework;QQ群:332035933;<UserControlx:Class="WpfBootstrap.View.ChartsView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://......
  • wpf datagrid绑定行选中状态
    样式如下<DataGridMargin="0,6,0,0"HeadersVisibility="All"RowHeaderWidth="60"HorizontalScrollBarVisibility="Visible"AutoGenerateColumns="False"ItemsSource="{BindingDispl......