w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Setting WPF image programmatically from a resource
When you have the opportunity to assign the ImageSource in code, I use BitmapToBitmapSource(Resources.image_name) with public static BitmapSource BitmapToBitmapSource(Bitmap bitmap) { return Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } This creates an BitmapSource which you then can assign as the ImageSource of your control.

Categories : C#

Cannot locate resource workflowdesigner.xaml When creating XAML Workflow Activity in Visual Studio 2010 using CRM 2011 SDK
That is a known bug. I contacted Microsoft and they confirmed it. I was told to look for a fix in UR 17. UR 16 was released in January so it should be out "soon". Update Rollup history: http://support.microsoft.com/kb/2555051/en-us (I realize this is a late reply, but it was a recent issue for me.)

Categories : Visual Studio 2010

Visual Studio: Differences between image paths set from the project window and programmatically set image paths
In first instance images are stored as a resouce file and are saved in the resources. Whereas in the second instance you specify the path where the image resides. Yes you can add image in resources progamatically if you are working in .net 4 or above. See this for details.

Categories : C#

jsf2 loading a resource bundle defined defined in a JAR
After some research it seems, resource-bundles defined in faces-config files in a JAR file are not resolved at run time. The only solution is to use <f:loadBundle var="msg" basename="messages"/> explicitly in the facelet page. Then it will resolve the messages.properties inside the JAR file.

Categories : JSF

force instantiation of xaml resource
public partial class App : Application { public NotificationIcon NotifyIcon {get;set;} protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); NotifyIcon = new NotificationIcon(); NotifyIcon.ApplicationExit += notificationIcon_ApplicationExit; } void notificationIcon_ApplicationExit(object sender, EventArgs eventArgs) { Application.Current.Shutdown(); } } ... And remove it from XAML.

Categories : C#

How to add canvas xaml resource in usercontrol
Add the Canvas and Path as a resource on the page or in the App.xaml or whatever, remember to set x:Key. Then use a ContentControl to reference the resource. <!-- In Resources, either on the Page or App.xaml for app-wide reuse --> <Canvas x:Key="TickCanvas" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="appbar_check" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0"> <Path Width="37.9998" Height="31.6665" Canvas.Left="19.0001" Canvas.Top="22.1668" Stretch="Fill" Fill="#FF000000" Data="F1 M 23.7501,33.25L 34.8334,44.3333L 52.2499,22.1668L 56.9999,26.9168L 34.8334,53.8333L 19.0001,38L 23.7501,33.25 Z "/> </Canvas <!-- On your page, or somewhere --> <ViewBox>

Categories : C#

In XAML how to copy a resource to a different tag name dynamically
Add the resource to your top Page.Resource (or Control.Resource). Then, access it using StaticResource. <Page.Resources> <SolidColorBrush x:Key="HighlightColor" Color="Yellow">/ </Page.Resources> <TextBlock Foreground="{StaticResource HighlightColor}"/>

Categories : C#

How to close window programmatically after calling window.showdialog?
When you launch the dialog using ShowDialog, the control goes to the newly opened dialog. So you need to do the close operation in the launched dialog. Alternatively, you can try window.Show(); Thread.Sleep(10000); window.Close(); DoEvents();

Categories : C#

UC with items defined into xaml?
I don't want to use a container to make my items visible, I only want to get the Children controls and put it into a List or Collection If they are not visual elements you can just create Lists on your user control Example: (using just FrameworkElement lists) UserControl: public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } public ObservableCollection<FrameworkElement> FirstCollection { get { return (ObservableCollection<FrameworkElement>)GetValue(FirstCollectionProperty); } set { SetValue(FirstCollectionProperty, value); } } // Using a DependencyProperty as the backing store for FirstCollection. This enables animation, styling, binding, etc... public static readon

Categories : C#

Datagrid (WPF) Column styling programmatically (not xaml)
Here's an example of adding a column with Style: XAML <Grid> <DataGrid x:Name="m_DataGrid" Width="400" AutoGenerateColumns="True" HorizontalAlignment="Left" RowHeight="20" ColumnWidth="*" AlternatingRowBackground="Beige" SelectionUnit="CellOrRowHeader" FontFamily="Consolas" FontSize="12" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserAddRows="False" CanUserDeleteRows="False"> <DataGrid.Resources> <Style TargetType="DataGridCell" x:Key="ColumnGo

Categories : Wpf

WPF IOException Cannot Locate Resource Dictionary XAML
I had the same problem with this SDK sample...Nitesh's comment above contained the answer that worked for me, i.e. prepend "/Shared/" to "LibraryControlRescourceDictionary.xaml" in the value for the Source attribute.

Categories : C#

Wpf merged resource dictionary no being recognized from app.xaml
I hava a big problem with MergedDictionaries and I believe that your problem is the same. I want my ResourceDictionaries to be properly organized, which means for me that there are for example seperate Buttons.xaml, TextBoxes.xaml, Colors.xaml and so on. I merge them in Theme.xaml, often all the Styles are in a seperate assembly (so that I could easily switch Themes). My ApplicationResources are as follows: <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/DefaultTheme;component/Theme.xaml" /> </ResourceDictionary.MergedDictionaries> <Style TargetType="{x:Type Ellipse}"/> </ResourceDictionary> </Application.Resources> And every StaticResource in the .xaml

Categories : Dotnet

How to add same object to resource dictionary with different keys in XAML
If you want to use the same template for all types I suppose you are going to use the property values converted to common types as string or object in the template. Create a wrapper class for those derived objects with the properties you want to bind to the template. These wrapper class needs one data template public class DerivedWrapper { //Properties you want to bind public DerivedWrapper(DerivedInt dInt) { //Set the properties } public DerivedWrapper(DerivedDouble dDouble) { //Set the properties } } And then <ResourceDictionary> <DataTemplate DataType="{x:Type local:DerivedWrapper}"> <!--content goes here--> </DataTemplate> </ResourceDictionary>

Categories : C#

Looping over XAML defined labels
You could add all those Label to a List<Label> within the form's constructor. It is a tedious work, but you'll only have to do it once. List<Label> labels = new List<Label>(); labels.Add(label1); // etc. // loop for (int i = 0; i < labels.Count; i++) labels[i].Text = i.ToString(); // alternative loop foreach (Label label in labels) label.Text = "test";

Categories : C#

Using control defined in XAML in another thread
No. WPF creates objects with thread affinity, and those objects can only then be used from the thread which created them. This means if you want to split your UI between threads each control must be created on the thread that is going to use it.

Categories : C#

XAML - How do I programmatically create a Path from mini-markup?
Ho hum. I found this workaround. Path o = (Path)XamlReader.Load(String.Format(@"<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Data=""{0}"" />", pathData));

Categories : C#

Access properties of elements defined in ControlTemplate in xaml
This is a very common question in WPF. You can access these elements if you named your Control control like this: TextBox textBox = (TextBox)control.Template.FindName("Address", control); ComboBox comboBox = (ComboBox)control.Template.FindName("Type", control); I trust that you can work the rest out for yourself.

Categories : C#

Is it possible to add another Window with XAML?
Right-click on your project in the solution explorer, and select add -> new item. In the list of available new items, select "Window (WPF)." This will add both the *.CS and *.XAML files, and will automatically link them together to make the new window function. You can then call the new window by using a variety of programmatic methods, depending on your needs. For example: private void Button_Click(object sender, RoutedEventArgs e) { Window1 w1 = new Window1(); w1.Show(); }

Categories : C#

Why does modifying project output directories cause: IOException was unhandled "Cannot locate resource 'app.xaml'."
WinFX and Xaml targets perform some behind the scenes hacks/magic when the Xaml references a type located within the current project. During this build task the wpf.csproj is copied to tempfilename.tmp_proj, several nodes related to assembly references are trimmed, and the file is compiled into the IntermediateOutputPath. This allows the Xaml compiler to reference types within the temp assembly.

Categories : C#

XAML browser window control
As far as I remember in WinForms, the WebBrowser version was the same as the version of IE installed on that machine, I'm assuming it's still the same in WPF. And no, you can't change the default control to use Chrome. There is however, a .NET implementation of Chromium which according to its documentation supports HTML5 as well.

Categories : C#

nullreferenceexception while creating window xaml
OK, so I found out what is happening, albeit on quite a high level, but it seems I can't start 2 ui's concurrently. As I stated in my question, I run the login ui and dashboard ui, and I start them in the way described above, that is start a thread with STA Apartment state, the new thread then new's the login window class and hands it over to the dispatcher. But after the new thread is started the main thread goes ahead and starts its work on the dashboard window in the same fashion and as it turns out, some part of that process cannot run concurrently with another thread. Not sure why, but thats how I resolved it. So basically the code for starting the ui's now look like this private AutoResetEvent _dashboardStartWaitEvent = new AutoResetEvent(false); internal void SetupAndRunDas

Categories : C#

Can you programmatically switch between xml resource files on android?
Yes you can. This is a copy/paste from a project doing so, based on user preference, to be put in onCreate(): Resources res = getResources(); Configuration conf = res.getConfiguration(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String def = Locale.getDefault().getDisplayLanguage(); String lang = prefs.getString("LANGUAGE", def); conf.locale = new Locale(lang); Log.v("myapp", lang+" = "+conf.locale+" = "+conf.locale.getDisplayName()); res.updateConfiguration(conf, res.getDisplayMetrics()); By setting a user preference named LANGUAGE to the two-letter code of the desired language, and then restarting the Activity, you manually override set the language. By removing the preference you get the system default.

Categories : Android

Modifying existing resource file programmatically
Here is a function that would help you modify the resource file. public static void UpdateResourceFile(Hashtable data, String path) { Hashtable resourceEntries = new Hashtable(); //Get existing resources ResXResourceReader reader = new ResXResourceReader(path); if (reader != null) { IDictionaryEnumerator id = reader.GetEnumerator(); foreach (DictionaryEntry d in reader) { if (d.Value == null) resourceEntries.Add(d.Key.ToString(), ""); else resourceEntries.Add(d.Key.ToString(), d.Value.ToString()); } reader.Close(); } //Modify resources here... foreach (String key in data.Keys) { if (!resourceEntries.ContainsKey(key)) { String va

Categories : C#

AngularJS - $resource is not defined
As suggested in the comments you need to create a controller or service that uses the $resource. Here is an example var app = angular.module('plunker', ['ngResource']); app.controller('MainCtrl', function($scope, $resource) { var dataService = $resource('http://run.plnkr.co/5NYWROuqUDQOGcKq/test.json'); $scope.data = dataService.get(); });

Categories : Javascript

XAML editor won't render the controls in my WPF window
Removing Opacity="0" from the window root tag makes the controls show in my Visual Studio. I tried to switch the opacity on back in case if code is running in the designer like this: public NfyWindow() { InitializeComponent(); if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) this.Opacity = 1; } —but this seems to be ignored by Visual Studio 2010. However the reverse trick helps: you can remove the opacity setting from the XAML and put it into the constructor. This worked for me, but your Visual Studio version/SP may be different. You may also try a cleaner way: public NfyWindow() { InitializeComponent(); if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) this.Opacity = 0; }

Categories : Wpf

Cannot find resource that is defined in ControlTemplate
Though the storyboard is placed in your Grid, try this: ((Grid)this.Content).FindResource("MyAnimation"); or, if it is possible, this.ToBeAnimated.FindResource("MyAnimation");

Categories : Wpf

Orchard - Can't find the Resource defined in ResourceManifest.cs
The issue here is, that the project Themes has a problem with the dynamic compile mechanism of Orchard (i don't know what is wrong exactly) because it resides in folder Themes. Even if you define a class inside the Themes assembly, it will result in an error telling you there is no such class in that assembly. solution : Try re-generating your theme with /CreateProject:true and /IncludeInSolution:true parameters as follows: codegen theme TestTheme /CreateProject:true /IncludeInSolution:true /BasedOn :TheThemeMachine It will create your theme in a separate project and orchard will pick your registered ResourceManifest. Hope this helps.

Categories : Asp Net Mvc

How to Access Window Object declared in App.xaml in class file in WPF?
Converting my comment to an answer. Namespace being used for Application appears to be System.Windows.Forms.Application rather than System.Windows.Application fix : (be explicit if needed or get rid of the using System.Windows.Forms; which you probably have somewhere in that scope) var currentApp = System.Windows.Application.Current as App; if (currentApp != null) currentApp.mainWindowObj.Title = "Hello";

Categories : C#

How to programmatically fire a dblclick event defined with addEventListener?
You can use dispatchEvent to programatically trigger events: var event = new MouseEvent('dblclick', { 'view': window, 'bubbles': true, 'cancelable': true }); document.getElementById('aa').dispatchEvent(event); See the section "Triggering built-in events" on MDN. Here is a fiddle of the code in action.

Categories : Javascript

Error creating bean with name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml]
java.lang.NoClassDefFoundError: javax/wsdl/WSDLException This is your problem. You need to add javax.wsdl API classes to your test class path. For example wsdl4j contains the class, so if you're using maven, try <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.3</version> <scope>test</scope> </dependency> If you don't use maven, you can download the jar from this link.

Categories : Spring

Calling a $resource action from inside a user defined $scope function
Introduction I solved my own problem. I used this Github comment from Misko Hevery as reference. Why my PUT request wasn't executing: Apparently, in Angular 1.1.x, if you ever leave the angular execution context, you'll be outside of Angular's $scope.$apply function. In my case, I was working with JQuery UI's sortable function - whenever a Card was placed in a new Deck, I wanted to update the Deck's cards to reflect that update. To the best of my understanding, because of this, I was outside the angular execution context. ngResource wouldn't execute the PUT statement and the $then function of the Angular's promise object will never be called. The solution: Simply wrapping the $scope.$apply function around the Card.updateaction allowed the action to execute, which subsequently allowe

Categories : Ruby On Rails

How do I programmatically add a statusbar to an WPF Window application using C#
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.statusbar.aspx Heres how to use Statusbars in WPF. Learning XAML will really help you even if it is a bit tedious.

Categories : C#

How can I programmatically open Powerpoint without seeing the window?
objPPT.Presentations.Open inputFile,,msoFalse It needs another comma objPPT.Presentations.Open inputFile,,,msoFalse The parms are: Presentations.Open "filename", boolReadOnly, boolOpenUntitled, boolWithWindow You're telling it to open the input file, read-only, not untitled and leaving the WithWindow parm at its default value (True) which opens WITH a visible window. Bear in mind that you can't write any code that selects anything (that requires a visible window), but since you're not doing this, you should be good to go. [APPENDED EDITS] Ansgar's correct (apologies for my earlier mistaken comment). We're not allowed to invoke PPT invisibly, BUT if you create/open a presentation windowlessly, PPT never appears. I'm not familiar enough with VBS scripting to work out the exact

Categories : Vbscript

access another window's application's resource
Sorry you didn't get help on the AutoIt forum, but what you are doing is far beyond the level of hobbyist coders, who make up most of our community. In theory you are right, everything is possible in programming. You can't access the data because you are a different process. To do so you'd have to create a block of memory in the other program, add some code, and execute it. That process is called injection. The process for injection is fairly simple, pretty much these function calls: _WinAPI_OpenProcess, _MemVirtualAllocEx, _WinAPI_WriteProcessMemory, CreateRemoteThread you'll have to write your own wrapper for, _WinAPI_WaitForSingleObject, _WinAPI_ReadProcessMemory, _MemVirtualFreeEx. Even once you've done that, you won't be able to just send the image list over to the new application

Categories : Windows

Programmatically Maximize Window On Half Of Screen
This can be done without p/invoke. Try this: Rectangle rect = Screen.PrimaryScreen.WorkingArea; rect.Width = rect.Width / 2; Bounds = rect; This will put the current window on the left of the primary screen. Then just add this to put it on the right of the screen. Location = new Point(rect.Width, 0);

Categories : C#

requirejs window not defined
I haven't done much in the region of runtime javascript, but I know that many of the libraries you know and are used to in browsers (document object model's "getElementById", local storage) are not available in runtimes like Grunt or Rhino. Your use of localStorage in that settings file appears to be the issue. Instead, you need to make use of whatever API is given to you. For instance, a quick search found some Grunt examples where they read/write to a file on the filesystem: http://gruntjs.com/sample-gruntfile Obviously, this would be impossible in a browser, as browsers don't let you access files; but you may as well take advantage of it in Grunt. You can also feature-detect which mode you're in with clauses like this: if (window) { ... } else if (grunt) { ... }

Categories : Javascript

Image Scaling on ImageView Resource vs. SD Card saved Image
in first you are calling getThumbnailFileName() so it's getting the pre-scaled image from source, but in the else statement you are calling the image from source, and then it's scaled based on your ImageView, so modifying your call to getFileName() instead of getThumbnailFileName() should help

Categories : Android

Setting window icon with a static resource
I've just answered to a question about icon too big in MahApps MetroWindow (Application icon stretches to title bar height when using MahApps.Metro) and same technique could give you a solution. Basically, you have to set MetroWindow.IconTemplate property: <MahApps:MetroWindow.IconTemplate> <DataTemplate> <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Margin="4" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="HighQuality"> <Rectangle> <Rectangle.Fill> <VisualBrush Visual="{StaticResource appbar_alien}" /> &l

Categories : Wpf

Compare Panel BackGround Image with Resource Image
The problem is that your current code will check if they are from same object (which is not the case). Check this thread: Comparing two images visually Public Function AreSameImage(ByVal I1 As Image, ByVal I2 As Image) As Boolean Dim MS1 As New MemoryStream Dim MS2 As New MemoryStream I1.Save(MS1, ImageFormat.Bmp) I2.Save(MS2, ImageFormat.Bmp) For I As Integer = 0 To CInt(MS1.Length) - 1 If MS1.ReadByte() <> MS2.ReadByte Then Return False Next Return True End Function If (AreSameImage(Panel0.BackgroundImage, My.Resources.Dinoback)) '...

Categories : Vb.Net

python 3.3 tkinter-- "window' is not defined'
your missing one line. You need to add window = Tk() so your code should look like: from tkinter import * window = Tk() window.title("Test Window") window.geometry('300x300') window.wm_iconbitmap('Generals.ico') # Generals.ico is a filename for the window icon lbl = tkinter.Label(window, text='Label') lbl.pack() window.mainloop() Not sure if this is 100% correct cause I'm using python 2.7. You might not need to capitalive the 'T' in tk()

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.