resourcedictionary

WPF ImageSource binding with Custom converter

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 23:42:13
I have a simple template for a combobox structured in this way: <ComboBox DockPanel.Dock="Left" MinWidth="100" MaxHeight="24" ItemsSource="{Binding Actions}"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" Width="100" /> <Image Source="{Binding Converter={StaticResource TypeConverter}}" /> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> So, if I use this code, everything works: <TextBlock Text="{Binding Name}" Width="100" /> <!--<Image Source="{Binding Converter={StaticResource TypeConverter}}" /> --> <Image

How to override a global style (that doesn't have an x:Key), or alternatively apply a named style to all type-targeted controls?

最后都变了- 提交于 2019-12-02 17:00:51
I declared a style that I want to apply to ALL the buttons in the project, the style resides in the ResourceDictionary: <Style TargetType="StackPanel"> <Setter Property="Orientation" Value="Horizontal" /> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/> </Style> Now, in some window, I want to inherit from this style but add a value: <Style TargetType="StackPanel"> <Setter Property="Margin" Value="5"/> </Style> The problem is that it doesn't inherit from the global style, in order to inherit I have to assign a key to the global style:

WPF: Sharing resources across assemblies

笑着哭i 提交于 2019-12-02 09:46:15
I previously posted a question on sharing resources across assemblies using Themes/generic.xaml and the ComponentResourceKey markup extension. The solution works nicely, but it requres all of the shared resources to be located in the generic.xaml resource dictionary. Mine is getting rather large, so I thought I would use merged dictionaries in generic.xaml to organize things. I have had no luck so far. I ran some tests using the demo from my previous post, and as soon as I move resources to a merged dictionary, the ComponentResourceKey fails, complaining that it can't find the source file for

Conditional Resources Creation WPF XAML Design / Run time

自古美人都是妖i 提交于 2019-12-02 09:03:15
问题 Following a first question on WPF Cascading Binding, I remarked that I had more Resources than desired defined in both the MainWindow and the UserControls : This is well seen in Snoop the MainWindow XAML has an "instance" of a MainWindow ViewModel that paints the 2 usercontrol in green and blue additionnaly there are 2 instances of usercontrol viewmodels for each of the 2 UserControls that would paint the inner circle in red My first Intention in the Usercontrol was to be able to see " live "

System.Drawing.Image from ImageSource in Resources

為{幸葍}努か 提交于 2019-12-02 08:58:41
My question is very similar to this one: wpf image resources and changing image in wpf control at runtime , but with a slight twist. Here is my ResourceDictionary.xaml: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ImageSource x:Key="DisconnectedIcon">Images/disconnect.png</ImageSource> <ImageSource x:Key="Synced">Images/tick.png</ImageSource> <ImageSource x:Key="NotSynced">Images/x.png</ImageSource> As for the C# code behind, I am able to load the ImageSource from the resources with the following.

WPF - Binding ResourceDictionary.Source to a ResourceDictionary Property of the Presenter\DataContext

自古美人都是妖i 提交于 2019-12-02 07:58:56
问题 The following View\ViewModel does not work (though I've tried): Presenter: class SelectListPresenter : INotifyPropertyChanged { public SelectListPresenter() { //init code } ResourceDictionary PossibleValues { get; } ResourceDictionary AddedValues { get; } } View: <UserControl ...> <UserControl.DataContext> <ViewModels:SelectListPresenter /> </UserControl.DataContext> <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries x:Key="Options"> <ResourceDictionary Source

Conditional Resources Creation WPF XAML Design / Run time

拈花ヽ惹草 提交于 2019-12-02 05:07:47
Following a first question on WPF Cascading Binding , I remarked that I had more Resources than desired defined in both the MainWindow and the UserControls : This is well seen in Snoop the MainWindow XAML has an "instance" of a MainWindow ViewModel that paints the 2 usercontrol in green and blue additionnaly there are 2 instances of usercontrol viewmodels for each of the 2 UserControls that would paint the inner circle in red My first Intention in the Usercontrol was to be able to see " live " how my control would look like ( I painted it red to distinguish this "model" from the green and blue

Referencing a merged resource dictionary in windows phone seven failing

自作多情 提交于 2019-12-01 20:45:15
I am currently building a WP7 app using the MVVMLight framework. I would like to add a resource dictionary to my app.xaml, however when I do it fails. Here is a snipit from the app.xaml <Application.Resources> <!--Global View Model Locator--> <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> <!--Merged Resource Dictionaries--> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="View/StyleResourceDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> Because I am using a ViewModelLocator that

searching and listing WPF resource dictionaries in a folder

亡梦爱人 提交于 2019-12-01 19:52:49
I'm making a WPF application that is going to have multiple skins branded in by our build system. Ideally we would like the application to list off the skins available as some builds will have one to many skins. At runtime is there a way to enumerate all the Resource Dictionaries in a specific folder? I want to avoid hard coding the XAML filenames in my codebehind as this is a changing situation. Sort of. You can enumerate all BAML (compiled XAML) files as follows: var resourcesName = assembly.GetName().Name + ".g"; var manager = new System.Resources.ResourceManager(resourcesName, assembly);

Referencing a merged resource dictionary in windows phone seven failing

不想你离开。 提交于 2019-12-01 19:18:17
问题 I am currently building a WP7 app using the MVVMLight framework. I would like to add a resource dictionary to my app.xaml, however when I do it fails. Here is a snipit from the app.xaml <Application.Resources> <!--Global View Model Locator--> <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> <!--Merged Resource Dictionaries--> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="View/StyleResourceDictionary.xaml"/> </ResourceDictionary