zoukankan      html  css  js  c++  java
  • WPF学习笔记-绑定非元素对象

    <Window x:Class="WPFdemo6.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:WPFdemo6"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <FontFamily x:Key="ZY">Resources TextBlock</FontFamily>
        </Window.Resources>
        <Grid Name="Grid">
            <WrapPanel Name="WrapPanel">
                <StackPanel Name="StackPanel">
                    <!--绑定系统字体信息-->
                    <TextBlock Name="TextBlock1"  Height="20" Width="200" Text="{Binding Source={x:Static SystemFonts.IconFontFamily},Path=Source}"></TextBlock>
                    <!--绑定资源信息-->
                    <TextBlock Name="TextBlock2" Height="20" Width="200" Text="{Binding Source={StaticResource ZY},Path=Source}"></TextBlock>
                    <!--绑定上层元素信息 Mode=FindAncestor 匹配的第一个 AncestorLevel=1-->
                    <TextBlock Name="TextBlock3" Height="20" Width="200" Text="{ Binding  Path=Name,RelativeSource={ RelativeSource Mode=FindAncestor,AncestorType={x:Type StackPanel},AncestorLevel=1}}"></TextBlock>
                    <!--其他几种待补充-->
                </StackPanel>
            </WrapPanel>
        </Grid>
    </Window>
    View Code
  • 相关阅读:
    Linux 期中架构 PHP
    Linux 期中架构 MySQL
    Python 示例 饮水记录
    Linux 期中架构 inotify
    Linux期中架构 全网备份案例
    分布式存储系统Ceph部署过程 · Jayden's Blog
    Go语言汇编器的设计
    linux基础3
    6.2.2 多余的列另起一行
    linux网络设备驱动2
  • 原文地址:https://www.cnblogs.com/anyihen/p/12927097.html
Copyright © 2011-2022 走看看