在WPF中,使用设计时间仅在创建USERCORTROL时设置TextBlock的文本

发布于 2025-02-09 10:53:15 字数 736 浏览 1 评论 0原文

<UserControl x:Class="MachineStatusPlugin.MachineStatus_UC"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"
             DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Mode=OneTime}"
             d:DesignHeight="7">

我想使用类似于DesignHeight和DesignWidth的内容来设置文本屏体的文本,按钮的内容以及在设计时间内仅使用标签的内容。这可能吗?我找不到有关可以通过system.componentmodel.designerproperties.isindesignmodeproperty修改的有关所附属性的任何文档。

<UserControl x:Class="MachineStatusPlugin.MachineStatus_UC"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"
             DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Mode=OneTime}"
             d:DesignHeight="7">

I want to use something similar to DesignHeight and DesignWidth to set the Text of a TextBlock, the Content of a Button, and the Content of a Label only during design time. Is this possible? I haven't been able to find any documentation as to what the attached properties are that can be modified with System.ComponentModel.DesignerProperties.IsInDesignModeProperty

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲸落 2025-02-16 10:53:15
<TextBlock>
    <d:DesignerProperties.DesignStyle>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Text" Value="Hi Designer" />
        </Style>
    </d:DesignerProperties.DesignStyle>
</TextBlock>
<TextBlock>
    <d:DesignerProperties.DesignStyle>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Text" Value="Hi Designer" />
        </Style>
    </d:DesignerProperties.DesignStyle>
</TextBlock>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文