我有两行WPF网格.第一行包含4列,每列包含一个Button.第二行包含colspan为3的用户控件.自定义控件包含另一个具有两列的Grid.
我想将UserControl网格中第一列的宽度设置为MainWindow网格中第二列的宽度.在下面的示例中,"嵌套列0"的宽度应与"列1"的宽度相同.
我尝试使用ElementName,但它没有成功.有什么想法怎么做?
<Window x:Class="TestElementName.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:trace="clr-namespace:System.Diagnostics;assembly=WindowsBase"
xmlns:local="clr-namespace:TestElementName"
Title="MainWindow" Height="200" Width="600">
<Grid Tag="YeahGrid" Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" Tag="Hallelujah" x:Name="ColDef2"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0">Column 0</Button>
<Button Grid.Column="1" Grid.Row="0" MinWidth="180">Column 1</Button>
<Button Grid.Column="2" Grid.Row="0" MinWidth="115">Column 2</Button>
<Button Grid.Column="3" Grid.Row="0">Column 3</Button>
<local:ucButton Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3" BorderBrush="Red" BorderThickness="1" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
用户控制如下:
<UserControl x:Class="TestElementName.ucButton"
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"
xmlns:trace="clr-namespace:System.Diagnostics;assembly=WindowsBase"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> …Run Code Online (Sandbox Code Playgroud) 我正在使用Burn构建一个WiX引导程序.我意识到如下所示的RegistrySearch实际上并没有搜索注册表.我使用Process Monitor来监视注册表访问.
<Property Id="NETFX35VERSION" Secure="yes">
<RegistrySearch Id="RegSearchNetFx35" Root="HKLM"
Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v3.5"
Name="Version" Type="raw" />
</Property>
Run Code Online (Sandbox Code Playgroud)
但是,当我使用该util功能时它工作正常并且注册表被查询得很好:
<util:RegistrySearch Root="HKLM"
Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v3.5"
Value="Version"
Variable="NETFX35VERSION" />
Run Code Online (Sandbox Code Playgroud)
这是WiX Burn工具的预期行为吗?