WPF auto 与 *

使用自动尺寸设置方式,可使用Auto值。表示自动适应显示内容的宽度, 如文本需要多长,控件就显示多长.如果存在显示不全的问题,就会截断显示。

<RowDefinition Height="Auto"></RowDefinition>

按比例尺寸设置方式,需要使用星号(*)

<RowDefinition Height="*"></RowDefinition>

如果界面中既有Auto又有*, 先分配Auto,最后分配*

直接上例子:

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <TextBox Margin="10" Grid.Row="0">This is a test.</TextBox>
        <StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
            <Button Margin="10,10,2,10" Padding="3">OK</Button>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在C#中使用WPF窗口来开发AutoCAD插件,你需要使用AutoCAD .NET API和WPF技术。以下是基本步骤: 1. 在Visual Studio中创建一个新的Class Library项目。 2. 添加对AutoCAD .NET API的引用。这可以通过添加对acdbmgd.dll和acmgd.dll的引用来完成。 3. 在项目中添加一个新的WPF窗口或用户控件。 4. 在WPF窗口中添加必要的控件和事件处理程序。 5. 在AutoCAD中加载插件并在需要时显示WPF窗口。 以下是一个简单的示例,演示如何在AutoCAD中使用WPF窗口: ```csharp using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using System.Windows.Controls; using System.Windows.Forms.Integration; namespace MyPlugin { public class MyCommands { [CommandMethod("MyCommand")] public void MyCommand() { // 获取当前文档和编辑器 Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; // 创建并显示WPF窗口 MyWpfWindow wpfWindow = new MyWpfWindow(); ElementHost.EnableModelessKeyboardInterop(wpfWindow); Autodesk.AutoCAD.ApplicationServices.Application.ShowModalWindow(wpfWindow); // 在控制台中显示选定的文本 PromptSelectionResult selRes = ed.GetSelection(); if (selRes.Status == PromptStatus.OK) { SelectionSet selSet = selRes.Value; foreach (SelectedObject selObj in selSet) { if (selObj.ObjectId.ObjectClass == RXClass.GetClass(typeof(DBText))) { DBText text = (DBText)selObj.ObjectId.GetObject(OpenMode.ForRead); ed.WriteMessage("Selected Text: " + text.TextString); } } } } } public class MyWpfWindow : UserControl { public MyWpfWindow() { // 添加WPF控件 TextBox textBox = new TextBox(); textBox.Text = "Hello, world!"; this.Content = textBox; } } } ``` 在这个示例中,我们在AutoCAD中创建了一个名为"MyCommand"的命令,当用户输入该命令时,会打开一个WPF窗口,并在控制台中显示选定的文本。WPF窗口中只包含一个文本框控件,其中包含"Hello, world!"文本。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值