在我的UWP应用中,在后面的代码中
val inputs: Array[Column]
def myUDF: UserDefinedFunction = udf {
(input1: String, input2: Timestamp, otherInputs: Double*) => ... }
df.withColumn(colName, myUDF(inputs:_*))
返回 false ;当我在使用UserControl的page.xaml中使用VisualStateManager xaml块时。
这是我的意思。这是使用用户控制的page.xaml:
VisualStateManager.GoToState(this,"Layout2",false);
从代码中,我试图更改布局状态。但不幸的是无法做到这一点。
我也曾尝试发送“ this.mainControl”而不是“ this”,但失败了。
<local:MainUserControl x:Name="mainControl">
<local:MainUserControl.QuestionContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Border x:Name="imageControl" Background="Red" Height="200" Width="200" Grid.Row="0" Grid.Column="0"/>
<Border x:Name="richTextBoxControl" Background="Yellow" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Layout1"/>
<VisualState x:Name="Layout2">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="imageControl" Storyboard.TargetProperty="(Grid.Column)">
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextBoxControl" Storyboard.TargetProperty="(Grid.Column)">
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</local:MainUserControl.QuestionContent>
</local:MainUserControl>
我还检查了我的命名空间两次,但无法解决此问题。
当我删除时请注意
VisualStateManager.GoToState(this.mainControl,"Layout2",false)
一切正常。
任何帮助将不胜感激。
谢谢。
编辑:这是我的MainUserControl.xaml
<local:MainUserControl x:Name="mainControl">
<local:MainUserControl.QuestionContent>
这是我的MainUserControl.xaml.cs
<UserControl
x:Class="MyProject.Pages.MainUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProject.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="#ededed">
<Grid.RowDefinitions>
<RowDefinition Height="227"/>
<RowDefinition Height="625"/>
<RowDefinition Height="227"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="692"/>
<ColumnDefinition Width="1000"/>
<ColumnDefinition Width="228"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="1" Grid.Column="1" Background="White" >
<StackPanel x:Name="panelQuestion">
<ContentPresenter Content="{x:Bind QuestionContent}"/>
</StackPanel>
</StackPanel>
</Grid>
}
答案 0 :(得分:1)
您需要将VisualStateManager.VisualStateGroups
作为根面板Grid
的直接子标记,如下所示:
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Layout1"/>
<VisualState x:Name="Layout2">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="imageControl" Storyboard.TargetProperty="(Grid.Column)">
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextBoxControl" Storyboard.TargetProperty="(Grid.Column)">
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<local:MainUserControl x:Name="mainControl">
<local:MainUserControl.QuestionContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Border x:Name="imageControl" Background="Red" Height="200" Width="200" Grid.Row="0" Grid.Column="0"/>
<Border x:Name="richTextBoxControl" Background="Yellow" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>
</local:MainUserControl.QuestionContent>
</local:MainUserControl>
</Grid>
然后,在此XAML页的代码后,您可以调用VisualStateManager.GoToState(this, "Layout2", false);
来更改视觉状态。