resourcedictionary

Insert a WPF Resource Dictionary into a class library via Visual Studio 2010

纵然是瞬间 提交于 2019-12-05 06:53:50
I have a class library and want to change the type so that I also can add a WPF resource dictionaries. I have added the WPF references and also tried to sync the AssemblyInfo.cs file with a project that allows the addition of such resource files, however without success. If I use the add-new-dialog from Visual Studio, the template for WPF resource dictionaries is not available - If I create the file manually and then reference it, all works fine. How can I change my project to a WPF custom control library project so that Visual Studio allows me to add WPF resource dictionaries. Or are there

Error when using x:Shared=“False” resources in external assembly in WPF

前提是你 提交于 2019-12-05 05:42:08
In our project we have a ResourceDictionary with some Icons that looks like this: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Canvas x:Key="Icon.Refresh" x:Shared="False" Width="32" Height="32" Clip="F1 M 0,0L 32,0L 32,32L 0,32L 0,0"> <Path .../> <Path .../> <Path .../> </Canvas> </ResourceDictionary> The x:Shared="False" attribute is needed, because else the icon would disappear when I use it in multiple views. Now we want to make another project with the same icons, so we decided to put them in

How to reuse layouts in WPF

坚强是说给别人听的谎言 提交于 2019-12-05 04:56:44
I'm trying to create a application that will be tabbed where each tab will have a button area and a view area. Now each tab will essentially have the same layout just different things in the layout and I wanted to be able to reuse the same layout so that I won't have to change at many places ( it's just not good programming ). Can I accomplish this using resources or perhaps Styles. Please supply a light code example if possible. EDIT: I've decided to add an example of what I'm trying to do because I'm still not getting it. Under each TabItem I'm trying to recreate this grid (It's a bit more

Unable to merge ResourceDictionary from a referenced project

北城余情 提交于 2019-12-04 23:37:15
问题 I have two assemblies that each provide a common set of styles and resources that I want to include in my application. I'm using merged dictionaries in my App.xaml in order to load them, and at runtime they were just fine. Unfortunately, these resources won't load at design time, filling my Errors window with messages about unresolvable resources and giving me a UI that doesn't represent what will actually appear. This is my App.xaml as it stands right now: <Application x:Class="ClientDebug

Using system types in XAML as resources

爱⌒轻易说出口 提交于 2019-12-04 22:37:19
I have encountered a situation where it would be very useful to specify a floating point value directly in XAML and use it as a resource for several of my UI pieces. After searching around I found a good amount of information on how to include the proper assembly (mscorlib) in your XAML so you can do just that. Unfortunately, I am getting an exception in one instance where I try to do this. Here is the following XAML that recreates the situation: <Window x:Class="davidtestapp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com

Images in XAML ResourceDictionary disappear on ToolBar when Menu opens

蹲街弑〆低调 提交于 2019-12-04 18:50:37
问题 I have started to move various common Image s into a ResourceDictionary and noticed an odd behavior in my WPF application. If the Image is used in a MenuItem and in a Button on a ToolBar , when I open the Menu the image disappears on the Button . <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Image x:Key="NewImage" Source="/SomeApplication;component/Resources/NewDocumentHS.png" Stretch="None"/> <!-

How to load external XAML ResourceDictionary

本小妞迷上赌 提交于 2019-12-04 16:06:42
How can I add ResourceDictionary dinamicly like this? ResourceDictionary template = new ResourceDictionary(); template.Source = new Uri("Design.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(template); With absolute Uri it working perfectly but from Relative doesnt. I use the XamlReader class to do this: string exeFilePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; string exeDirPath = Path.GetDirectoryName(exeFilePath); string targetFile = "subfolder\\dictionary.xaml"; string path_to_xaml_dictionary = new Uri(Path.Combine(exeDirPath,

Nested Resource Dictionary in separate library

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 13:52:16
问题 My question is very similar to this one I have a solution with a number of projects. The are two that are relevant: a class library that contains a WPF window and a project with all the WPF styles in it. Class Library with the window in Project 1 The Window's merged dictionary is something like: <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/StyleAssembly;component/CommonStyle.xaml"/> </ResourceDictionary.MergedDictionaries> //other styles here The

Access ResourceDictionary in Windows Phone project from Shared project in App.xaml of Universal 8.1 App

我怕爱的太早我们不能终老 提交于 2019-12-04 13:49:38
I am creating a Windows Universal 8.1 app. In the Windows Phone 8.1 project inside I have a certain Xaml file as ResourceDictionary. In the Shared Folder I have the common App.xaml of the 2 projects (Windows and Windows Phone). Path of ResourceDictionary is: "MyApp.WindowsPhone/Assets/Styles/JumpList.xaml" In App.xaml I add: <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MyApp.WindowsPhone/Assets/Styles/JumpList.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> But I am getting: An error occured while finding the resource

Set Style for user control

蹲街弑〆低调 提交于 2019-12-04 12:11:15
I am trying to set a style for my user control. The UserControl is in a project "Controls" and the theme is in a project "MainProject" <UserControl x:Class="Controls.OutputPanel" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Name="OutputControl"> <!-- Style="{DynamicResource UserControlStyle}"> - I cant set the style here because the Resource Dictionary hasn't been