我在使用共享尺寸组时遇到问题。
直到我更改文本框值才能正常工作:
更改文本框的值后,将减小文本框大小:
我认为问题在于更新,因为当我尝试通过“实时可视树”选择网格时,问题空间消失了。
有人知道如何解决这个问题吗?
<ControlTemplate TargetType="{x:Type Controls:ElementEditor}" >
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" x:Name="MainBorder">
<StackPanel Orientation="Horizontal" x:Name="MainStack" DataContext="{Binding Path=., RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}">
<Border Visibility="{Binding Element.Value, Converter={StaticResource NullToVisRev}, ConverterParameter=Collapsed}" HorizontalAlignment="Left">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition>
<ColumnDefinition.SharedSizeGroup>
<MultiBinding Converter="{StaticResource ColumnGroupNameGen}">
<Binding Path="Element.Name" UpdateSourceTrigger="PropertyChanged"/>
<Binding Path="ParentElement.Name" UpdateSourceTrigger="PropertyChanged"/>
</MultiBinding>
</ColumnDefinition.SharedSizeGroup>
</ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox x:Name="PART_cellText" Text="{Binding Path=Element.Name,UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource HeaderTextbox}" />
</Grid>
</Border>
<StackPanel>
<TextBox Text="{Binding Path=Element.Name,UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
x:Name="Header"
Visibility="{Binding Element.Value, Converter={StaticResource NullToVis}, ConverterParameter=Collapsed}"
Style="{DynamicResource HeaderTextbox}"/>
<ItemsControl ItemsSource="{Binding Element.Value}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Controls:ElementEditor x:Name="PART_Header"
Element="{Binding}"
ParentElement="{Binding ElementName=MainStack, Path=DataContext.Element,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource ElementHeaderTable}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</StackPanel>
</StackPanel>
</Border>
</ControlTemplate>
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value[0]!=null)
{
string GroupName;
GroupName = value[0].ToString();
if (value[1] != null)
{
GroupName = value[1].ToString() + GroupName;
}
System.Diagnostics.Debug.WriteLine(GroupName);
return String.Format("Group{0}", GroupName);
}
return 0;
}