在DataGridTemplateColumn.CellTemplate中使用DataStateBehavior? [英] Using DataStateBehavior in a DataGridTemplateColumn.CellTemplate?

查看:58
本文介绍了在DataGridTemplateColumn.CellTemplate中使用DataStateBehavior?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Expression Blend团队在7月份提供的示例,其中包括DataStateBehavior以及两个VisualStates和DataGridTemplateColumn.CellTemplate中的数据绑定。

代码如下所示:< br $> b $ b

<! - 想象一下DataGrid定义的其余部分 - > 
< data:DataGridTemplateColumn.CellTemplate>
< DataTemplate>
< Grid>
< VisualStateManager.VisualStateGroups>
< VisualStateGroup>
< VisualState x:Name =" AddState" />
< VisualState x:Name =" EditState">
< Storyboard>
< ObjectAnimationUsingKeyFrames BeginTime =" 00:00:00"持续时间=" 00:00:00.0010000" Storyboard.TargetName = QUOT; AddTextBlock" Storyboard.TargetProperty = QUOT;(UIElement.Visibility)">
< DiscreteObjectKeyFrame KeyTime =" 00:00:00">
< DiscreteObjectKeyFrame.Value>
<可见性>折叠< /可见性>
< /DiscreteObjectKeyFrame.Value>
< / DiscreteObjectKeyFrame>
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames BeginTime =" 00:00:00"持续时间=" 00:00:00.0010000" Storyboard.TargetName = QUOT; EditablePanel" Storyboard.TargetProperty = QUOT;(UIElement.Visibility)">
< DiscreteObjectKeyFrame KeyTime =" 00:00:00">
< DiscreteObjectKeyFrame.Value>
<可见性>可见< /可见性>
< /DiscreteObjectKeyFrame.Value>
< / DiscreteObjectKeyFrame>
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< / VisualStateGroup>
< /VisualStateManager.VisualStateGroups>
< i:Interaction.Behaviors>
< id:DataStateBehavior Binding =" {Binding Comment}"值= QUOT; {X:空}" TrueState = QUOT; AddState" FalseState = QUOT; EditState" />
< / i:Interaction.Behaviors>

< TextBlock x:Name =" AddTextBlock" Text =" {Binding Incentives_ListView_Add,Source = {StaticResource LocStrings}}" Style =" {StaticResource TextLinkStyle}" />
< StackPanel x:Name =" EditablePanel"能见度= QUOT;折叠"取向= QUOT;水平"的MouseLeftButtonUp = QUOT; EditCommentsClicked" Style =" {StaticResource EditCommentsPanelStyle}">
< Image Source =" ../../ Images / EditIcon.png" Style =" {StaticResource CommentsIconStyle}" />
< TextBlock Text =" {Binding Incentives_ListView_Edit,Source = {StaticResource LocStrings}}" Style =" {StaticResource TextLinkStyle}" />
< / StackPanel>
< / Grid>
< / DataTemplate>
将/数据:DataGridTemplateColumn.CellTemplate>


解决方案

Hello orangechicken


您对Valye ="{x:Null}"进行的比较将它绑定到注释将永远不会在这种情况下工作,因为

 绑定 
=
"
{Binding Comment}
"

永远不会知道它发生了什么。可能是它的bcuz模式=没有设置拖车或任何其他原因。此外,Value必须与任何现有控件的某些属性绑定。就像在我的情况下,我也有两个不同的状态Visible和
Collapsed,所以你必须与"Value"进行某种比较。说一个文本框的文本,所以这里是样本


试试这个


< ei:DataStateBehavior TrueState =" AddState" FalseState = QUOT; EditState"
值="" Binding =" {Binding Text,ElementName =" ABCtextbox ",Mode = TwoWay}" />


现在当 ABCtextbox的值为空时,您的地址将被激活,否则编辑状态将被激活。


或者如果您我可以帮助您切换要切换这些状态的属性,我想提供帮助。


BR,


-Ali


I'm using the samples provided in July by the Expression Blend team which includes DataStateBehavior in combination with two VisualStates and a data binding within a DataGridTemplateColumn.CellTemplate.

The code looks like this:

    <!-- Imagine the rest of the DataGrid definition here -->
    <data:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Grid>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup>
                        <VisualState x:Name="AddState"/>
                        <VisualState x:Name="EditState">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="AddTextBlock" Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Collapsed</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="EditablePanel" Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                        <DiscreteObjectKeyFrame.Value>
                                            <Visibility>Visible</Visibility>
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <i:Interaction.Behaviors>
                    <id:DataStateBehavior Binding="{Binding Comment}" Value="{x:Null}" TrueState="AddState" FalseState="EditState"/>
                </i:Interaction.Behaviors>

                <TextBlock x:Name="AddTextBlock" Text="{Binding Incentives_ListView_Add, Source={StaticResource LocStrings}}" Style="{StaticResource TextLinkStyle}"/>
                <StackPanel x:Name="EditablePanel" Visibility="Collapsed" Orientation="Horizontal" MouseLeftButtonUp="EditCommentsClicked" Style="{StaticResource EditCommentsPanelStyle}">
                    <Image Source="../../Images/EditIcon.png" Style="{StaticResource CommentsIconStyle}"/>
                    <TextBlock Text="{Binding Incentives_ListView_Edit, Source={StaticResource LocStrings}}" Style="{StaticResource TextLinkStyle}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </data:DataGridTemplateColumn.CellTemplate>

解决方案

Hello orangechicken

the comparison you are making of Valye="{x:Null}" with binding it to comment will never work in this case, as

Binding
=
"
{Binding Comment}
"

will never get to know what happenes with it. May be its bcuz the mode=towway is not set or anyother reason. Also the Value must be bound with some Property of any existing control. Just like in my case where i also have two different states Visible and Collapsed, so you have to make some sort of comparison with "Value" say of a textbox's text so here is the sample

try this

<ei:DataStateBehavior TrueState="AddState" FalseState="EditState" Value="" Binding="{Binding Text, ElementName="ABCtextbox ", Mode=TwoWay}"/>

now when the ABCtextbox's value us empty, your addstate will be activated else Edit state will active.

Or if you can eleborate to what propertychage you want to toggle these states, i will like to help.

BR,

-Ali


这篇关于在DataGridTemplateColumn.CellTemplate中使用DataStateBehavior?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆