w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Use MessageDialog/MessageBox with Portable Class Library and MVVM Light
Your instinct is correct, but there are more than a few ways of going about this. First and foremost, you can use Mvvm's Messaging library, which will allow your ViewModel to send messages directly to your View. Your View can then handle it in any way it wishes, including but not limited to using a MessageDialog. Secondly, you can also create a Function or Action (likely the former) in your ViewModelLocator for ShowMessageDialog. This Function will likely take a string and return a Task. Then, after you initialize your ViewModelLocator initially, you can inject your ShowMessageDialog code. Your ViewModels can then use whatever platform's MessageDialogs that they please. Ex: Note: This code uses the BCL Async libraries that are accessible in Nuget. They work in the PCL just fine. ViewM

Categories : Windows Phone 8

Exposing commands for MVVM user control inside GridView in WinRT
There are two methods for doing this. first one that you can use is - bind your button to a command that is defined- in your parent viewmodel where you can do your work. second one is - you can use mvvm messenger class. in which you have to send message from your button click eventhandler to your viewmodel. when you received this message add some eventhandler to it and perform your work there.

Categories : Xaml

How to make Behaviors contain other Behaviors in reactive-banana
To manage a dynamic collection of behaviors, you have to use dynamic event switching. See the BarTab.hs example for a demonstration. However, dynamic event switching can be a bit unwieldy and it is often possible to avoid it. Two common situations are: The collection of behaviors is known statically. The TwoCounters.hs demonstrates that one can simply use the applicative functor combinators to calculate a value depending on either behavior. The dynamic collection can be modeled as a behavior of a collection (Behavior [a]) as opposed to a collection of behaviors ([Behavior a]). The Asteroids.hs example demonstrates how to use this. This is a stylistic trade-off: the individual entries of the collection cannot be formulated with FRP anymore, but the collection becomes easier to manage.

Categories : Haskell

How to determine using C# Reflection if a class is a WinRT type
From http://blogs.msdn.com/b/ptorr/archive/2012/05/27/loading-winrt-types-via-reflection-in-windows-8.aspx It looks like you can get the AssemblyQualifiedName and see if it contains ContentType=WindowsRuntime.

Categories : C#

different between class library and portable class library in visual studio
The Portable Class Library project type enables you to write and build managed assemblies that work on more than one Microsoft platform, whereas the "normal" Class Library project type doesn't. "Microsoft platforms" include .NET Framework, Windows Phone, .NET for Windows Store Apps, Silverlight, Xbox; all in various versions or flavors. Source Go through this for converting from one class library to another type. (See also: this relevant SO question.)

Categories : Visual Studio

Soap service call from a class library is failing when I call the class library. Works in a console app
I have been able to call a WCF service within a Project Server Event Receiver DLL. In order to do so, please follow these "tricks": 1.- For configuracion purposes, the DLL's (you code) execute within the Microsoft.Office.Project.Server.Eventing.exe process, which is located (in a default configuration) on: "C:Program FilesMicrosoft Office Servers14.0Bin". For custom installs open the task manager and right click the "Microsoft.Office.Project.Server.Eventing.exe" and select go to file. So, any configuration you need to be written in a file needs to be put in that directory insede the file: "Microsoft.Office.Project.Server.Eventing.exe.config". I have used this file to put a Database Connection String and I've been able to read it with the System.Configuration library. However, not all con

Categories : Web Services

WinRT - Windows Store - WinRT Originate Error - How do decipher such an error?
As Raman said - it's good to look up the hex values shown. The first one is the memory location which won't tell you much without the symbols/source, which in this case is reported directly by Windows. Perhaps the public symbols can shed some more light on where the error came from, but the error code lookups are more helpful. If you Bing for 0x80070057 you will find an MSDN article on Common HRESULT Values which lists E_INVALIDARG : One or more arguments are not valid : 0x80070057 It doesn't give you all the details of course, so you're off to theorize. Perhaps you can only call args->GetCurrentPoint(nullptr) once and you should store/reuse the value? Maybe gesture recognizer is not configured correctly? Maybe the app window is not visible at the time the exception is thrown or t

Categories : Visual C++

Adding Class Library Reference to WCF Service Library
I was able to find a similar question: WCF service library project can't find reference to other project I changed the project's target framework from .NET Framework 4 Client Profile to .NET Framework 4 which seems to have fixed the compiling issue.

Categories : C#

MVVM - Access command from different class in XAML
I've fixed the problem. All I had to was this: <Button Content="New Game" Command="{Binding GameViewCommand}" DataContext="{Binding Main, Source={StaticResource Locator}}" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" /> <Button Content="Say Hello" Command="{Binding SayHelloCommand}" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" /> Turns out it was a very easy fix.

Categories : C#

How to handle property changed event of a property in One class from another class in MVVM
You can subscribe the event PropertyChanged. myModel.PropertyChanged+=(s,e)=>{ /* your handler here */}; as the @stijn comment point, unsubscribing can be required if the model became unused to avoid memory leaks.

Categories : C#

Creating a custom image class in WPF following MVVM pattern
As far as my understanding of MVVM and your question goes, I have one main comment about your code. I think your CustomImage is actually both Model and ViewModel layer, and you should split it in two : the Model, which would contain the path itself ; the ViewModel, which contain the BitmapImage and initialize it from the Model and constructing time. The path is the mere data used for saving, and it fits the Model, whereas the BitmapImage is how the data is shown and should be constructed in the ViewModel. One advantage is that now, your BitmapImage gets its own NotifyPropertyChanged call at setting time, and you won't have anymore problem or a View part directly bound to the Model. As for your CustomImageViewModel, this looks like more of a MainViewModel-ish thing. You can still use

Categories : C#

Can't reference a C# class library within a VB.NET class library
This is because you cannot create circular references. If the ddl of your first project is referenced in the second one there is no way you can add the other project as a reference also. When building the solution both projects would depend on each other and this will fail.

Categories : C#

ObjectiveC passing class Pointer to static library and then calling methods from class
Declare a protocol like this in your static library: @protocol AppDelegateRequiredMethods @required ... methods here ... @end Then, import the header that declares that protocol into your various AppDelegate implementations and declare your app delegate as implementing said protocol: @interface MyAppDelegate:NSObject <AppDelegateRequiredMethods> ... @end

Categories : Iphone

Create a Date class with fields day, month and year. (You cannot use the built-in DateTime class from .NET Library)
You want to make your own class myDateTime that has ints Day, Month, Year. Then you'll want to make a while(userinput != 0) loop where your program begins. When you receive input, you'll want to validate each integer, and then, if the data is valid, create an instance of myDateTime with the values. An example for data validation: if(userInputDay >= 1 && userInputDay <= 31 ) myDateTime.Day = userInputDay; From your code: if (value <= 30) Day = value; else if (value == 31) Day = value; else if (value == 28) Day = value; Is the same logic as: if(value <= 31) Day = value; Here's a start for you, it's pretty dumb and doesn't do any error checking but it's a start class Program { static void Main(string[] args) { Console.WriteLine("Input Month

Categories : C#

Could I use Java servlet Filter class from other referenced class library?
If the exception is ClassNotFoundException this means that you haven't set the class MyClassLibrary in the classpath of your application. Make sure that your class MyClassLibrary is referenced from the app of this web.xml. Regards.

Categories : Java

class library and pimpl - splitting class accessibility
There are pros and cons. By a source stand point, if you distribute only headers and binaries, everything in in cpp files will not be seen by the source user. So, also MyPartiallyVisibleClass::Impl::Usermethod is not visible, but being public, callable everywhere in the cpp file it is declared. Zero way, one way or two way friendship between external and internal class can be required if you don't want to repeat external methods internally. It can seem an encapsulation break, but it is not, since the "capsule" here, is the external class. Creating complex hierarchy of intenal privacy (public external, private external, public internal private internal public even more internal ... etc.) can become clueless if everything goes under your same responsibility. Unless the internal part is so

Categories : C++

Different looping behaviors in Groovy
In the first loop you're changing a local variable that never updates what is in the array. num holds a copy of the data in the array element, but there's no reference back to the array entry, so changing it has no effect on the array. This way is a little groovier than the old-style for-loop: for (i in 0..x.length - 1) { for (j in 0..y.length - 1) { x[i][j] = 5 } } or you can do without the for: (i in 0 .. x.length - 1).each { i -> (j in 0 .. y.length - 1).each { j -> x[i][j] = 5 } }

Categories : Java

`if else` with or without `()` behaviors different in css transformer of Lift?
I guess it has to do with the operator precedence and the way code is parsed. To get a very precise answer one would have to look closely at Scala's spec. In general, I would recommend to write a function for @a and another for @b to make things really clear when reading code. E.g.: def ta = if (true) "@a" #> "xxx" else "@a" #> "yyy" def tb = "@b" #> "zzz" val t1 = ta & tb Scala has a very lightweight syntax that encourages such definition unlike many other programming language. Your code tend to be much more readable when using it. Have a look at Odersky's talk on Scala with Style. He explains other interesting tricks too.

Categories : Scala

Why different behaviors for OOME while trying to catch it?
My understanding is that, in the first program, the OOME is thrown when trying to allocate a new Long object, which takes only a few bytes of memory. This means that the heap is completely full, and that no memory is available anymore to run the catch block. In the second program, the OOME is thrown when trying to allocate a new array of 1 million bytes. It fails, but that can mean that the heap still has 999,990 bytes available, which is enough to let the catch block execute.

Categories : Java

Class library does not recognize CommandManager class
Go to the "References" part of your class library and select "Add Reference". Look for an assembly called "PresentationCore" and add it. Then in your class file add the using statement using System.Windows.Input; You will then be able to access the CommandManager as you expect. Just adding: lots of guys when they go to create a class library, they select "WPF Custom Control Library" and then erase the "Class1.cs" file. It's a shortcut that automatically adds the right namespaces to your library. Whether it's a good or bad shortcut is anybody's call, but I use it all the time.

Categories : C#

How to copy objects behaviors into another from the same type?
label2.font = label1.font; label2.textColor = label1.textColor; If you have a lot of this labels it would make sense to add them to an array and "copy" the properties in an enumerated loop. You might want to take a look at this answer - it shows a way of deep-copying a label.

Categories : Iphone

MySQL : Different behaviors depending on WHERE result
Like this you'll have 3 virtual columns: SELECT COUNT(IF(seg.my_seg1 >= 30, 1, 0)) AS res1, COUNT(IF(seg.my_seg1 >= 11 AND seg.my_seg1 < 30, 1, 0)) AS res2 FROM ( SELECT COUNT(DISTINCT cp.conference_id) as my_seg1 FROM A.Account a JOIN A.ConferenceParticipant cp ON a.account_id = cp.user_id JOIN A.Conference cf ON cf.id = cp.conference_id WHERE cf.`status` = 0 AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= cf.creation_timestamp GROUP BY a.account_id ) AS seg But you have to revise your filters, you talk about 3 but I only see 2 different ones.

Categories : Mysql

Weird Behaviors of time in Rails application
This solved the problem. heroku config:add TZ="Asia/Seoul" in application.rb config.time_zone = 'Seoul' config.active_record.default_timezone = :local Then, Time.zone.now == Time.now I will update this later with details.

Categories : Ruby On Rails

How can I make the height behaviors of table tag and div tag work the same?
[UPDATED ANSWER] I see what's happening here. Your div has padding-top:100px which makes its total height 100% + 100px. Your table has the same thing, but the table does weird things so that it doesn't cause the issue. E.g. the table always stretches to fill the space in a way that the div won't. Note how the word "body" is centered with your table but not with your div. If you remove the padding-top:100px; from the div CSS, it fixes the issue, except then your middle area overlaps the header. Since you can't edit your HTML, you can use CSS to give whatever the first element in the main section a margin-top of 100px, to put that buffer back in there without adding to the height of the div. Something like this should work: div.middle:first-child{ margin:top: 100px; } [OLD ANSWER] H

Categories : HTML

Different HTTP POST behaviors from Objective C and from JQuery
Look at the documentation of jquery.post() ( http://api.jquery.com/jQuery.post/ ): jQuery.post( url [, data ] [, success(data, textStatus, jqXHR) ] [, dataType ] ) dataType Type: String The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). The fourth variable is the expected data type from the server. So your second variable ({hist_id: 15}) isn't being converted to json. That's why it's being sent as a normal post variable.

Categories : Jquery

Best practice: Create custom control or implement using behaviors?
If you are a designer that work in Blend you can easily mix and match behaviors. A custom control can of course also be used in Blend but only the properties and styling can be modified by the designer. As far as I know behaviors were developed by the Blend team to better facilitate "development" by a non-developer. So behaviors have some advantages when working in Blend.

Categories : Wpf

Doctrine Behaviors fields in Symfony2 auto-generated CRUD
app/console doctrine:generate:crud command use generate:doctrine:form command which generate fields for all entity properties. So yes, you must remove unnecessary fields from form OR use more advenced generators like AdmigeneratorGeneratorBundle.

Categories : Symfony2

How to implement reactive-banana behaviors that recursively depend on themself?
The exception is correct, you are defining a behavior directly in terms of itself. alternater .. active = (.. <$> active <*> .. , ..) ui b = do let (behavior, ..) = alternater .. (.. <$> b) return $ .. <*> behavior ... mfix ui This code means that the current value of the result behavior in ui would depend on itself in a circular way. Recursion always needs a little delay to be well-defined. The most convenient way to do that is to use mutual recursion between an event and a behavior built with stepper or accumB. See also this answer.

Categories : Haskell

Why doesn't tracing behavior appear to work when added to Autofixture Fixture.Behaviors in an AutoDataAttribute implementation?
I had to do a little digging to figure out why this is happening. The reason you're seeing this behaviour is that when you use the default constructor of TracingBehavior, Console.Out is the destination. When executing a test case, the xUnit.net test runner assigns another TextWriter to Console.Out. This happens before the code block in the test method is executed, which explains why the first test in the OP displays the trace: when the TracingBehavior instance is created, Console.Out is already the captured TextWriter. However, in the second test (using the [TracingFixtureConventions] attribute), Console.Out has not yet been replaced when the attribute's constructor runs. So, when this test runs, it actually traces to the original Console.Out, but since there's no console present, it t

Categories : Misc

Output in txt in C# Class library
public override void OnDeleting(PSContextInfo contextInfo, ProjectPreEventArgs e) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:Blah.txt")) { string textToWrite = string.Format("Пользователь "{0}" удалил проект "{1}"", contextInfo.UserName, e.ProjectName); sw.WriteLine(textToWrite); } } Something like this. Use StreamWriter object. EDIT Obviously make sure you have access to write to the C: drive etc or wherever you want to write too.

Categories : C#

Accessibility in .Net Class Library
You have to set all of you class public if you have some public access to them (via the Main class). Otherwise you can set the internal class as internal and provide a set of properties in the Main class (that wrap internal classes' fields/methods) in order to access their field/methods. You can set the constructors of internal class as internal in order to avoid those class instantiations. In general: Every field/method exposed from a public class should have a public return type. Some MSDN reference

Categories : C#

How to localize a WP8 class library?
I found a way but it's rather a work around. The solution is not to try to localize your controls from XAML, but instead from your behind code. For example, you define a Button in XAML as follows: <Button Name="MyButton" /> And then in your partial class behind you set the content of the button programatically as follows: MyButton.Content = MyLocalizedStrings.Hello; Of course, in this example you would have a resource file called "MyLocalizedStrings.resx" in your project with a string named "Hello" in it. This approach solves the problem. The only down side is that you won't be able to see a preview of the localized XAML in the Visual Studio XAML window.

Categories : C#

DBContext in Class Library
Of Course it is possible to use DBContect in a class library, this is what I am currently doing in my projects, I just point them to the DLL(class library) I suspect your app.config file is missing the connection string in the class library project. add it , it should be the same: <connectionStrings> <add name="DBModelEntities" connectionString="metadata=res://*/Model.Model.csdl|res://*/Model.Model.ssdl|res://*/Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.SQLEXPRESS;initial catalog=TEST_DATABASE;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> Don't forget to recompile to see the changes.

Categories : Asp Net Mvc

Qt: mingw compiled library does only work with both library.so and library.lib file present
That's weird, I think you should get a *.a and *.dll files when building a shared lib with MinGW on Windows, as said in the documentation: In windows, MinGW will output .a and .dll, MSVC2010 will ouput .lib and .dll. In linux, MinGW will output .so, .so.1, .so.1.0 and .so.1.0.0 – .lib, .a and .so are import libraries. You definitely shouldn't rename your file! Be careful to: not to include the "lib" prefix after "-l" in your project file. put everything after after "-l" in lower case as you're on Windows not adding any extension to your library name after "-l" add and reference the .h file used in your library A real example using QtWebsocket lib: INCLUDEPATH += "$${PWD}/include/" LIBS += -L"$${PWD}/libs/" -lqtwebsocket ... HEADERS += ... $${PWD}/include/QWsSocket.

Categories : Qt

HttpApplicationState outside of the Web Project (Class Library)
Using HttpContext.Current.Application you should be able to access HttpApplicationState in the outside classes. Update But I agree with John Saunders - business logic should not be aware of where it is called from.

Categories : Asp Net

Limit access to a Class library in C#.NET
I think your best bet would be InternalsVisibleTo attribute Ordinarily, types and members with internal scope (in C#) and friend scope (in Visual Basic) are visible only in the assembly in which they are defined. The InternalsVisibleToAttribute attribute makes them also visible to the types in a specified assembly, which is known as a friend assembly. The attribute is applied at the assembly level. This means that it can be included at the beginning of a source code file, or it can be included in the AssemblyInfo file in a Visual Studio project Of course this doesn't prevent people from calling your methods using reflection

Categories : Dotnet

Portable Class Library Testing
It's usually best to test on all platforms. Right now I'm not aware of any test framework/runner that supports this. I'm hoping to help xUnit do so. I've done a very simple implementation of a test framework for my PCL Storage library. So you could use that to get you started running tests on all the platforms.

Categories : Dotnet

StreamReader and Portable Class Library
found the answer over here (by Rob Caplan): http://social.msdn.microsoft.com/Forums/windowsapps/en-US/386eb3b2-e98e-4bbc-985f-fc143db6ee36/read-local-file-in-portable-library#386eb3b2-e98e-4bbc-985f-fc143db6ee36 File access cannot be done portably between Windows Store apps and Windows Phone 8 apps. You will have to use platform specific code, to open the file and acquire a stream. You can then pass the stream into the PCL. Since both Windows Store apps and Windows Phone 8 apps use the essentially the same Windows (Phone) Runtime classes from Windows.Storage to open files you can share the code (but not the binary) by linking a code file between the two projects. See Share code with Add as Link . See Maximize code reuse between Windows Phone 8 and Windows 8 for

Categories : C#

how to validate e-mail using class library in vb.net
to create class library Go to File Menu -> New -> Project. Select Project Type “Visual Basic” and Template “Class Library”. Give project name as “EmailValidation” and click OK. Public Class Class1 Public Function email(ByVal str As String) As Boolean Dim str1 As String str1 = str If InStr(str1, "@") > 0 Then If InStr(str1, ".") > 0 Then Return True Else Return False End If Else Return False End If End Function End Class Select Build -> Build Solution or press ctrl+shift+B. to create dll file

Categories : Vb.Net

Including external dll's into my class library dll
You can use iLMerge tool for this. iLMerge is a tool provided by Microsoft. Download it from here http://www.microsoft.com/en-in/download/details.aspx?id=17630

Categories : C#

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