相关疑难解决方法(0)

wpf绑定到索引器

<TextBlock Text="{Binding Path=[0]} />
Run Code Online (Sandbox Code Playgroud)

要么

<TextBlock Text="{Binding Path=[myKey]} />
Run Code Online (Sandbox Code Playgroud)

工作良好.但有没有办法将变量作为索引键传递?

<TextBlock Text="{Binding Path=[{Binding Column.Index}]} />
Run Code Online (Sandbox Code Playgroud)

.net data-binding wpf xaml indexer

14
推荐指数
2
解决办法
7741
查看次数

VS2010(Blend 3)中不存在"Interaction.Behaviors"标签

在VS2010 xaml编辑器中支持Blend 3的Interactivity命名空间似乎存在问题.我安装了以下内容:

  • VS2010
  • Blend 3 + Blend 3 SDK

我正在尝试编译一个针对.Net 4 Client Profile的演示项目,并引用System.Windows.Interactivity(在Blend 3文件夹中).

在对象浏览器中,一切似乎都很好.我也可以从代码隐藏中访问Interaction.Behaviours,但如果我将命名空间xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"放在xaml文件中并尝试使用它,则intellisense为空.

如果我在那里复制一些东西,编译器说: The tag 'Interaction.Behaviors' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'.

我是否需要安装Blend 4 RC或其他东西?

wpf xaml visual-studio-2010 expression-blend

12
推荐指数
4
解决办法
3万
查看次数

<i:Interaction.Behavior>选项不适用于应用beahviour

我一直在尝试在wpf窗口上实现一个行为,因此我在当前的解决方案中添加了对System.Winodws.Interactivity的引用,然后编写了所需的行为.但是为了应用这种行为,我必须在Windows XAML中编写类似的东西.

<Window x:Class="WpfApplication5.MainWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="MainWindow" Height="350" Width="525" 
        xmlns:behav ="clr-namespace:WpfApplication5" 
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity;assembly=System.Windows.Interactivity">
    <Window.Resources>
        <i:Interaction.Behaviors>
            <behav:DialogIconRemoveBehavior></behav:DialogIconRemoveBehavior>
        </i:Interaction.Behaviors>
    </Window.Resources>
    <Grid>

    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

但这不是有效的标签,因为我可能必须添加对System.Windows.Interactivity的任何其他程序集的引用,所以,请建议我在XAML中使用标签时还需要做些什么

wpf xaml blend mvvm attachedbehaviors

6
推荐指数
1
解决办法
1万
查看次数

如何在列表视图的组标题中保存 IsExpanded 状态 - 练习 2

为了获得一些上下文,这个问题指的是How to save the IsExpanded state in group headers of a listview

我在这里缺少什么?

当我尝试按照参考帖子中的建议进行操作时,我得到:

BindingExpression 路径错误:在“对象”“ExpandStateManager”上找不到“[]”属性

我的展开状态管理器

public class ExpandStateManager
{
    Dictionary<Category, bool> expandStates = new Dictionary<Category, bool>();

    public bool this[Category key]
    {
        get
        {
            if (!expandStates.ContainsKey(key)) return false;
            return expandStates[key];
        }
        set
        {
            expandStates[key] = value;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

XAML

    <ListView ItemsSource="{Binding Source={StaticResource cvs}}"  ItemTemplate="{StaticResource animalTemplate}"
     Width="200">
        <ListView.GroupStyle>
            <GroupStyle>
                <GroupStyle.ContainerStyle>
                    <Style TargetType="{x:Type GroupItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type GroupItem}">
                                    <Expander IsExpanded="{Binding Source={StaticResource ExpandStateManger}, Path=[Items[0].ObjectType]}">
                                        <Expander.Header>
                                            <DockPanel>
                                                <TextBlock Text="{Binding …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf

3
推荐指数
1
解决办法
2419
查看次数

GroupStyle 和 Expander.IsExpanded 绑定的问题

我对 GroupStyle 和 Expander.IsExpanded 绑定有疑问。我的代码基于这个答案:How to save the IsExpanded state in group headers of a listview from @user1。我无法对此答案发表评论,因为我的声誉不够高,所以这就是我提出这个新主题的原因。

在我的 ListView 中,我有以下代码:

<!-- Group Container Style -->
<ListView.GroupStyle>
    <GroupStyle>
        <GroupStyle.ContainerStyle>
            <Style TargetType="{x:Type GroupItem}">
                <Setter Property="Margin" Value="0,0,0,5"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GroupItem}">
                            <Expander IsExpanded="{Binding Path=Items[0].bIsExpandedGroup}">
                                <Expander.Header>
                                    <DockPanel>
                                        <TextBlock FontWeight="Bold"
                                            Style="{StaticResource DefaultTextBlockItemStyle}"
                                            Text="{Binding Path=Name}"
                                            />
                                    </DockPanel>
                                </Expander.Header>
                                <Expander.Content>
                                    <ItemsPresenter />
                                </Expander.Content>
                            </Expander>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </GroupStyle.ContainerStyle>
    </GroupStyle>
</ListView.GroupStyle>
Run Code Online (Sandbox Code Playgroud)

属性“bIsExpandedGroup”绑定在 DTO_Package 上(绑定到 ListView 的对象)

public class DTO_Package : ViewModelBase
{
    (...) …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml mvvm

1
推荐指数
1
解决办法
714
查看次数