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
  • 相关阅读:
    BaseJob
    BaseWorkerForm
    MainForm()
    OperationSystemForm
    Job1
    ExeCuteManager
    ThreadPool
    LogEntry
    java学习阶段一 常量
    java学习阶段一 数据类型
  • 原文地址:https://www.cnblogs.com/anyihen/p/12927097.html
Copyright © 2011-2022 走看看