Tag: xaml

如何创build基于默认样式的样式?

如何在Silverlight中创build基于默认样式的样式? 例如,在WPF中,我们使它像这样: <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"> <Setter Property="Margin" Value="2" /> <Setter Property="Padding" Value="2" /> </Style>

将WPF(XAML)控件转换为XPS文档

我可以使用现有的WPF(XAML)控件,将其数据绑定并将其转换为可使用WPF XPS文档查看器进行显示和打印的XPS文档? 如果是这样,怎么样? 如果不是,我应该如何使用XPS / PDF /等在WPF中进行“报告”? 基本上我想采取一个现有的WPF控件,数据绑定它获得有用的数据,然后使其可打印和可保存的最终用户。 理想情况下,文档创build将在内存中完成,除非用户专门保存文档,否则不会打到磁盘。 这可行吗?

在运行时加载XAML?

首先是一些背景:我正在研究一个应用程序,我正在尝试遵循MVVM约定写它。 我想要做的一件事就是能够给应用程序提供不同的“皮肤”。 同一个应用程序,但为一个客户端显示一个“皮肤”,为另一个客户显示不同的“皮肤”。 所以我的问题是: 1.是否可以在运行时加载xaml文件并将其“分配”给我的应用程序? 2. xaml文件可以是驻留在不同文件夹中的外部文件吗? 3.应用程序能否轻松地切换到另一个xaml文件,或仅在启动时间? 那么我应该从哪里开始寻找这方面的信息呢? 哪些WPF方法(如果存在)处理这个function? 谢谢! 编辑:我想要做的“剥皮”的types不仅仅是改变我的控件的外观。 这个想法是有一个完全不同的用户界面。 不同的button,不同的布局。 有点像一个版本的应用程序将完全为专家function,另一个版本将简化初学者。

如何从触发器绑定到另一个控件的属性?

在我的特殊情况下,我想绑定到TextBox的IsReadOnly属性来设置Button的Content属性? 它们都是同一个StackPanel的一部分。 我试着用一个DataTrigger来绑定到TextBox的ElementName和一个使用TextBox名称作为SourceName的触发器。 有什么想法吗?

无法引用包含合并字典的资源字典

我有一个库,CommonLibraryWpfThemes,里面有几个Resource Dictionary XAML文件。 我的主题/ Generic.xml文件包含将所有其他文件合并在一起的ResourceDictionary.MergedDictionaries声明。 Generic.xaml <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/BrushDictionary.xaml" /> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/TextBlockDictionary.xaml" /> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/LabelDictionary.xaml" /> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/ButtonDictionary.xaml" /> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/ResourceDictionaries/WindowDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> 在我的应用程序项目中,我引用了CommonLibraryWpfThemes,并且在App.xaml文件中明确引用了Generic.xml。 App.xaml – 失败 <Application x:Class="MyApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Application.Resources> <ResourceDictionary Source="/CommonLibraryWpfThemes;component/Themes/Generic.xaml" /> </Application.Resources> </Application> 这不起作用。 我运行我的应用程序时出现以下错误: System.Windows.Markup.XamlParseException occurred Message="Cannot find resource named '{_fadedOrangeBrush}'. Resource names are case sensitive. […]

什么是每个WPF文件中的xmlns?

什么是xmlns ? 在创buildWPF项目时,它在XAML文件中起什么作用?

我怎样才能连接xaml和xaml.cs文件

我有一个VB投影,并使用在线转换工具将其转换为C#。 现在问题是xaml和xaml.cs文件不能相互连接,也就是说他们不能识别它们的依赖关系(图中的红色区域)。 实际上,它应该像Window1文件(图像中的绿色区域)。我怎样才能实现这一点。 我正在尝试使用WPF,所以可能是一个普通人的问题。

在XAML中绑定到Self /'this'

简单的WPF / XAML问题。 在XAML中,如何在给定的上下文中引用Self / this对象? 在一个非常基本的应用程序中,窗口的主窗口,一个控件和一个编码的C#属性,我想将控件的属性绑定到窗口的手工编码属性。 在代码中,这很容易 – 在Window的构造函数中,我添加了这个: Binding bind = new Binding(); bind.Source = this; bind.Path = new PropertyPath("ButtonWidth"); button1.SetBinding(WidthProperty, bind); 很明显,我有一个名为ButtonWidth的属性,以及一个名为button1的控件。 我无法弄清楚如何在XAML中做到这一点。 像下面的例子的各种尝试没有奏效: <Button x:Name="button1" Width="{Binding Source=Self Path=ButtonWidth}"/> <Button x:Name="button1" Width="{Binding RelativeSource={RelativeSource Self} Path=ButtonWidth}"/> 等等 谢谢

在WPF DataGrid中的文本alignment

如何将列数据alignment到WPF DataGrid ?

在工具提示中添加分隔线

¿如何将分隔符添加到XAML中的工具提示中的文本? 我尝试这个: <Label Name="label4" UseLayoutRounding="False" Focusable="False" AllowDrop="False" Foreground="Black" Margin="6,44,132.027,76" ToolTipService.ShowDuration="12000"> <Label.ToolTip> <ToolTip> <TextBlock>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </TextBlock> <TextBlock>Suspendisse eget urna eget elit ullamcorper tincidunt. Sed nec arcu sed ante sodales </TextBlock> <TextBlock>Pellentesque elit libero, semper ac tincidunt vitae, euismod at ligula.</TextBlock> </ToolTip> </Label.ToolTip> <Label.Content> <TextBlock TextAlignment="Right" TextWrapping="Wrap" Height="19" Width="108" >Lorem Ipsum</TextBlock> […]