标签: expression-blend

设计ListPicker Blend/Xaml

我正在使用ListPicker,但很难让设计工作.我已经包括了我做过的测试:

 <ControlTemplate x:Key="listpicker_style" TargetType="toolkit:ListPicker">
        <StackPanel>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="PickerStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="Highlighted">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="UserControl"
                                Storyboard.TargetProperty="Foreground"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneTextBoxForegroundBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="Background"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneTextBoxEditBackgroundColor}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="BorderBrush"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneTextBoxEditBorderBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="Background"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource TransparentBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="Border"
                                Storyboard.TargetProperty="BorderBrush"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneDisabledBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames
                                Storyboard.TargetName="UserControl"
                                Storyboard.TargetProperty="Foreground"
                                Duration="0">
                                <DiscreteObjectKeyFrame
                                    Value="{StaticResource PhoneDisabledBrush}"
                                    KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <ContentControl
                Content="{TemplateBinding Header}"
                ContentTemplate="{TemplateBinding …
Run Code Online (Sandbox Code Playgroud)

c# xaml expression-blend listpicker windows-phone-8

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

如何使用Expression Blend编辑在Visual Studio中创建的DataTemplate?

对于那些在实际项目中使用Expression Blend和Visual Studio的人,请帮助我了解如何在日常开发/设计任务中使用Blend和Visual Studio,这是一个真实的场景:

我在Visual Studio中创建了以下简单的WPF应用程序.它显示了一个带有DataTemplate的客户对象列表,该对象以简单的橙色框显示客户.

我现在通过使用Expression Blend 将一些pizazz放入这个DataTemplate中.

在Expression Blend中打开这个项目,以为我会看到橙色的盒子,我可以改变它的颜色,在鼠标悬停时创建动画,调整大小等等.但是,我在Expression Blend中看到的只是一个完全空白的盒子.

所以我理解:

  • Expression Blend 似乎无法理解我的数据来自ViewModel,因此不会显示它.这是Blend的限制还是我需要以某种方式更改我的代码,以便Blend可以解释在运行时会出现什么数据?
  • 我正在使用具有"样本数据"功能的Expression Blend 3.使用此示例数据功能的最佳方法是什么,即使它无法解释C#并了解将从ViewModel属性中填充Listbox的哪些数据,我怎样才能使它至少产生一些虚拟数据,以便我可以操纵DataTemplate?

XAML:

<Window x:Class="TestStringFormat234.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <DataTemplate x:Key="DataTemplateCustomers">
            <Border CornerRadius="5" Background="Orange" Padding="5" Margin="3">
                <StackPanel Orientation="Horizontal">
                    <TextBlock>
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0} {1} (hired on {2:MMM dd, yyyy})">
                            <Binding Path="FirstName"/>
                            <Binding Path="LastName"/>
                            <Binding Path="HireDate"/>
                        </MultiBinding>
                    </TextBlock.Text>
                    </TextBlock>
                </StackPanel>
            </Border>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <ListBox …
Run Code Online (Sandbox Code Playgroud)

c# wpf expression-blend

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

如何在每个XAML文件中没有合并的ResourceDictionary的Blend/VS中获得WYSIWYG设计?

我刚刚为我删除了一个大内存问题,我曾经在每个xaml文件中合并我们的"Themes"资源字典,而不是仅仅在app.cs.xaml中.

但是,在删除除App.cs.xaml之外的每个文件中的合并之后,我丢失了设计时样式/模板.

请注意:这仅适用于合并到我们的Themes.xaml中的样式(例如Color.xaml,Brushes.xaml - 我们为每种类型的样式都有一个).直接在Themes.xaml(我们没有..)中定义的东西有效.

我看到两个解决方案,

1)在XAML中注释掉合并,当我想使用设计时,只需取消注释.

2)在每个控件的默认控制器中都有这个:(也许只适用于Blend)

#if DEBUG
Resources.MergedDictionaries.Add(
                new ResourceDictionary()
                {
                    Source = new System.Uri(@"RD.xml")
                }
                );
#endif
Run Code Online (Sandbox Code Playgroud)

任何人都知道,必须有更好的方法来设计页面和控件的设计时间?

谢谢!

wpf expression-blend

8
推荐指数
2
解决办法
2653
查看次数

在'ViewModelLocator类型中找不到属性'IsDataSource'

我有以下代码:

<UserControl x:Class="TestApp.View.ViewAlarmLog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit"  
 xmlns:mvvm="clr-namespace:Test.ViewModel">
<UserControl.Resources>
    <ResourceDictionary  >
        <ResourceDictionary.MergedDictionaries>
        </ResourceDictionary.MergedDictionaries>
        <mvvm:ViewModelLocator x:Key="Locator" d:IsDataSource="True"/>
  </ResourceDictionary>
 </UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)

问题是数据我总是得到一个错误:在'ViewModelLocator'类型中找不到属性'IsDataSource'."

这可能是什么问题?

Redgards Dieter

mvvm expression-blend

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

在WPF中设计时间数据

[使用vs2010和表达式混合v4]

嗨 - 尝试在WPF和Blend中加载一些设计时数据,使用Josh Smith的概念:http://joshsmithonwpf.wordpress.com/2010/04/07/assembly-level-initialization-at-design-time/ eg

[AttributeUsage(AttributeTargets.Assembly)]
public class DesignTimeBootstrapperAttribute : Attribute
{
    public DesignTimeBootstrapperAttribute(Type type)
    {
        var dep = new DependencyObject();
        Debug.WriteLine("here..?");
        if (DesignerProperties.GetIsInDesignMode(dep))
        {
            // TODO: Design-time initialization…
            IBootstrapper instance = Activator.CreateInstance(type) as IBootstrapper;
            if (instance != null)
            {
                instance.Run();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的属性在AssemblyInfo.cs中,AppBootstrapper扩展了MefBootstrapper.

[assembly: AssemblyCopyright("Copyright ©  2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: DesignTimeBootstrapper(typeof(AppBootstrapper))]
Run Code Online (Sandbox Code Playgroud)

我不想使用Blend样本数据,a)因为它似乎没有为ObservableCollection创建数据而b)我按照定义处于设计模式,因此事情会发生很大变化,但我的'生成的数据' 将不会.

无论如何,似乎没有任何事情发生.

Q1:如何调试我的bootstrapper的设计时初始化?Q2:我的View XAML中是否需要额外的混合命名空间/属性等?

(在我的引导程序中,我只是注册了一个不同的模块,我想用DesignTimeService替换RunTimeService,导出IService接口).

TIA

wpf design-time mvvm expression-blend

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

使用Expression Blend编辑DataTemplate,用于使用DataTemplateSelector的项目

我是我的应用程序,我有一个ItemsControl元素,其中包含用户绘制的形状.每个特定形状的ViewModel都继承自基础ViewModel.DataTemplateSelector基于形状的ViewModel类型应用正确的DataTemplate.

在我的胜利xaml:

    <ItemsControl ItemsSource="{Binding MarkupElements}"
                  ItemTemplateSelector="{StaticResource MarkupTemplateSelector}"/>
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas Panel.ZIndex="1" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ItemsControl>
Run Code Online (Sandbox Code Playgroud)

在资源字典中:

    <DataTemplate x:Key="MarkupLineTemplate" DataType="x:Type vm:MarkupLineViewModel">
    <.../>
    </DataTemplate>
    <DataTemplate x:Key="MarkupCircleTemplate" DataType="x:Type vm:MarkupCircleViewModel">
    <.../>
    </DataTemplate>
    <view:MarkupTemplateSelector
    LineTemplate="{StaticResource MarkupLineTemplate}"
    CircleTemplate="{StaticResource MarkupCircleTemplate}"
    x:Key="MarkupTemplateSelector"/>
Run Code Online (Sandbox Code Playgroud)

这很好用,但Expression Blend不允许我编辑这些模板.我可以强制Blend应用一个特定的模板,但它会ItemTemplate在我的win.xaml中添加一个属性,设置为我选择的,覆盖选择器.

我正在使用MVVM Light Tookit,并尝试添加一些不同类型的设计时形状.Blend会显示它们,但它们对访问模板没有帮助.

有没有办法说服Blend我的派生ViewModel对DataContext有效,从而允许我编辑模板?这甚至是问题吗?

wpf expression-blend

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

在ContentPresenter中将样式应用于Path(基于OnOn不工作!)

我无法将MouseOver样式应用于ContentPresenter内的Path.

我有一个包含ContentPresenter的Button样式:

<Style x:Key="ContentButton" TargetType="{x:Type Button}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
                <ContentPresenter
                x:Name="contentPresenter"
                Content="{TemplateBinding Content}">
                    <ContentPresenter.Resources>
                    <Style TargetType="{x:Type Path}"
                        BasedOn="{StaticResource ContentButtonPathStyle}"/>
                    </ContentPresenter.Resources>
                </ContentPresenter>
Run Code Online (Sandbox Code Playgroud)

这是一种风格,所以我可以在路径上有一个翻转效果:

<Style x:Key="ContentButtonPathStyle" TargetType="{x:Type Path}">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Fill" Value="#FF00FF10"/>
            <Setter Property="Stroke" Value="Red"/>
            <Setter Property="StrokeThickness" Value="6"/>
        </Trigger>
    </Style.Triggers>
    <Setter Property="Stroke" Value="Red"/>
    <Setter Property="Fill">
        <Setter.Value>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFB4B3E7" Offset="0"/>
                <GradientStop Color="#FF0800FF" Offset="1"/>
            </LinearGradientBrush>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

我还有一个图标资源文件,其中包含一个包含路径的Viewbox:

<Viewbox x:Key="MyIcon">
    <Grid>
        <Path Data="M78,296 L37.5,306.5 45.5,354.5 123.5,343.5 z" />
    </Grid>
</Viewbox>
Run Code Online (Sandbox Code Playgroud)

最后,我创建了一个按钮并将Viewbox资源分配给内容:

<Button Style="{DynamicResource ContentButton}"> …
Run Code Online (Sandbox Code Playgroud)

wpf expression-blend

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

将VS2010项目加载到Expression Blend时,属性无法识别或无法访问错误

我在VS2010项目使用XAML,现在我需要将其加载到Expression Blend的4项目建立和运行VS2010,这是它已经被加载到混合的第一次.即使成员未被识别,它也可以在Blend中构建和运行.

为什么Scale属性无法识别?为什么它在功能上有效时会显示为错误?

编辑虽然这构建和运行,但XAML不会在Blend中以图形方式显示,因此非技术用户无法修改.

在许多包含对usercontrols的引用的.xaml文件中,Blend无法识别出错误的属性:

The member "XXXX" is not recognized or is not accessible
Run Code Online (Sandbox Code Playgroud)

该属性存在于.cs代码隐藏文件中,并且在每种情况下错误消息都是相同的.

我在互联网上看了很多可能的答案,但没有一个是解决方案.引用的项目不是只读的.各种类和属性都是公共的.我还将以下WPF引用添加到.csproj文件中,该文件丢失了.

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Run Code Online (Sandbox Code Playgroud)

在以下代码中,即使Scale属性作为用户控件中的属性存在,也无法识别它.

这是MyLogo.xaml中的UserControl:

<UserControl x:Class="NamespaceX.NamespaceY.UI.Shapes.MyLogo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="132" Width="105">
<Canvas>
    <Canvas.LayoutTransform>
        <ScaleTransform x:Name="st" CenterX="0" CenterY="0" />
    </Canvas.LayoutTransform>
    <Image Source="/Client;component/Images/MyLogo.png"/>
</Canvas>
Run Code Online (Sandbox Code Playgroud)

以下是MyLogo.xaml.cs中的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace NamespaceX.NamespaceY.UI.Shapes
{
/// <summary>
/// Interaction logic for MyLogo.xaml
/// </summary>
public partial class …
Run Code Online (Sandbox Code Playgroud)

wpf visual-studio-2010 visual-studio expression-blend expression-blend-4

8
推荐指数
2
解决办法
2万
查看次数

如何获得Visual Studio 2013 Express的Blend

微软明确提及如何下手混合这个文章没有指向任何版本限制的Visual Studio 2013.

我安装了Visual Studio 2013 Express,显然没有Blend的痕迹,肯定没有外部链接可以下载并安装VS2013.

你能否告诉我们Visual Studio附带的Blend版本以及微软谈论此事的最佳参考?

谢谢

wpf expression-blend visual-studio-2013

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

Binding ="{Binding(0)}"是什么意思?

我找到了这个:

<DataTrigger Value="True" Binding="{Binding (0)}">
Run Code Online (Sandbox Code Playgroud)

RibbonMenuButton模板中的触发器.这是什么意思?我试过谷歌,但一无所获.

UPD更多代码:

<ControlTemplate x:Key="RibbonMenuButtonControlTemplate1" TargetType="{x:Type RibbonMenuButton}">
...
    <DataTrigger Binding="{Binding (0)}" Value="True">
        <Setter Property="TextElement.Foreground" TargetName="MainGrid" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
        <Setter Property="PathFill" TargetName="TwoLineText" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
        <Setter Property="CornerRadius" TargetName="OuterBorder" Value="0"/>
        <Setter Property="Background" TargetName="OuterBorder" Value="Transparent"/>
        <Setter Property="BorderBrush" TargetName="OuterBorder" Value="Transparent"/>
    </DataTrigger>
...
Run Code Online (Sandbox Code Playgroud)

RibbonMenuButton控件上按下"编辑模板"按钮后,在Blend中创建此代码.

wpf datatrigger controltemplate expression-blend ribbon-control

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