staticresource

MergedDictionaries and Resource lookup

痴心易碎 提交于 2019-12-28 05:14:14
问题 i have a problem with Resource dictionaries and mergeddictionaries in general, especially when it comes to resource-lookup performance. After some performance testing i found that ResourceDictionary.get_MergedDictionaries is the call with the most hits (checked in ANTS profiler). We have around ~300 resource dictionary xamls, and a lot of them are using merged dictionary to "include" other styles. Well the get_MergedDictionaries count on one part of our application, where not much is

Static resource constructor with parameters

喜夏-厌秋 提交于 2019-12-24 03:17:51
问题 I have to create in my XAML file a static resource. <Window.Resources> <vm:ViewModel x:Key="viewModel" /> </Window.Resources> I need this static resource to get the items for my combobox ItemsSource="{Binding Source={StaticResource viewModel}, Path=GetItems, Mode=TwoWay}" But how can I give the ViewModel (constructor) a instance of my code behind class? 回答1: If I understand this correctly, you are violating the MVVM pattern. You should never provide items from the ComboBox into your VM. You

Referencing a StaticResource in another StaticResource

你说的曾经没有我的故事 提交于 2019-12-23 02:58:07
问题 I'm trying to set up my styles properly. Thus I've created an external ResourceDictionary for all common style attributes, in which I've defined a default font family like this: <FontFamily x:Key="Default.FontFamily">Impact</FontFamily> This way the family changes at all places when I change this single line. using and referencing StaticResource Now I want to use this default font family wherever nothing else is defined, which is in most places (but not all). However, I want to retain the

Using system types in XAML as resources

♀尐吖头ヾ 提交于 2019-12-22 01:27:08
问题 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"

wpf datagrid combobox binding staticresource list of keyvalue pairs

梦想的初衷 提交于 2019-12-13 03:36:20
问题 I hope someone can help me or post a link to related question, that would have the answer. I have read most of them and thats how I got this far... So I have a datagrid with 3 columns, two of them are binded to one datatable and the third one that is a comboboxcolumn should be binded to the other one. I binded the combobox column to a static resource. What I don't uderstand how to transform a datatable to a list of keyvalue pairs that I want to use as a static resource for my comboboxcolumn.

Static resources in WPF in pluggable application

强颜欢笑 提交于 2019-12-11 11:41:57
问题 I am currently working on an enterprise WPF application and I am experiencing some issues with static resources: globally defined styles and converters. The application works this way: There is a shared host WPF application that is used as host for components developed by different teams (it's a PRISM application and MEF is used for importing plugins) Each team can add plugins by creating new dlls, but cannot modify other teams' dlls No changes can be made to the host application My team is

msdn Data Templating Overview

百般思念 提交于 2019-12-11 04:33:40
问题 I'm following msdn data templating overview http://msdn.microsoft.com/en-us/library/ms742521.aspx But I felt they missed explaining something..for resources they have: <Window.Resources><local:Tasks x:Key="myTodoList"/></Window.Resources> And all they have in XAML is <ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList}}"/> Without showing how C# code behind, they were able to show a list of items in the ListBox. The ListBox has no x:Name and I can't add

Failed to assign to property 'Windows.UI.Xaml.Controls.ContentControl.Content'

无人久伴 提交于 2019-12-10 22:38:31
问题 In my windows 10 app I want to set button content from a resource file. In the designer the vector image from the resource file is visible. But in runtime the following exception occurs: An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in Demo.UI.W10.exe but was not handled in user code WinRT information: Failed to assign to property 'Windows.UI.Xaml.Controls.ContentControl.Content'. [Line: 15 Position: 17] Additional information: The text associated with this error

Trying to animate a SolidColorBrush static resource

烂漫一生 提交于 2019-12-10 18:42:18
问题 What I'd like I want to reuse some styles across multiple UserControl types. I would like the background of some Border controls to flash, and I'd like them all to use the same style, static resource and animation, so that they all flash in sync. How I'm trying to do it To that end, I have defined some common colours in a resource dictionary, like so: <SolidColorBrush x:Key="StatusErrorBackground" Color="#440000" /> ...and I have also defined a StoryBoard in this dictionary, like so:

create multiple copies of staticresource

落爺英雄遲暮 提交于 2019-12-10 13:58:25
问题 I have a template for items control shown below. I need separate instances of colorProvider for each item in the template. Each item in the items control requires a seperate instance of the Color Provider depending on the item it is bound to. How do i create multiple copies of staticresource so that the staticresource is only available for that item. <ItemsControl x:Name="itemsControl" ItemsSource="{Binding DataList}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation=