« first day (1049 days earlier)      last day (3100 days later) » 

user868935
3:55 AM
Is it possible to have a win32 window displayed on a winforms panel in WPF?
 
5:15 AM
@SpicyWeenie Should be, using Win32 methods to set the Win32 window's parent to the HWND of the Winforms panel. I've done similar things before. They've always been fragile, because Win32 apps often do weird tricks that can break.
4
Q: How to change a Window Owner using its handle

Ricardo AmoresI want to make a .NET Form as a TopMost Form for another external App (not .NET related, pure Win32) so it stays above that Win32App, but not the rest of the apps running. I Have the handle of the Win32App (provided by the Win32App itself), and I've tried Win32 SetParent() function, via P/Invoke...

Is there a good reason my main window's LayoutChanged event is firing every 30ms or so? Even when nothing is happening in the app?
 
 
1 hour later…
6:25 AM
Moorning
@Mat'sMug wasn't it you that asked about the grouped list. So I had a further look at my project and I have something like it, however I believe I actually created an extra list from the first (so in your case I would generate a list with the results in some way), I don't really remember how I did it, and it was confusing to look at now :)
Oh and by the way I was using a TreeView look at this: wpf-tutorial.com/treeview-control/…
 
 
1 hour later…
7:46 AM
any one here?
 
Yes, hi
 
So this is just so stupid, but i'm trying to do it anyways... hold on...`
foreach (ResultGroup group in GroupedList)
{
    UnGroupedList.ToList().ForEach(x => (x.result == group.Result)?group.Results.Add(x));
}
it's just that this doesn't work since the ternary operator needs a "else"
 
x => { if /*...*/ }
 
! thanks !
 
you're welcome
 
7:49 AM
have you been there yourself? or did you just came up with that?
 
mmh I just know I need { } when there's more than one line in the lambda
 
I guess that if might be a multi line expression
 
there can be a single expression without {}
i find this way more readable:
        foreach (ResultGroup group in GroupedList)
        {
            group.Results.AddRange(UnGroupedList.Where(x => x.result == group.Result));
        }
if it works :), i haven't tested it
 
agreed :)
 
8:05 AM
The WPF perf toolkit shows that my app is constantly spending ~3% CPU time on Dispatcher.Invoke, and 0.5-3% CPU on Rendering and on Layout. Even when the UI is idle.
Does this make sense?
 
good morning everyone!
 
@NovitchiS almost great, just that my Results is a ObeservableCollection (so no AddRange)
 
anyone know how to select all items in a listview through a button click?
I am currently trying to use a command to do it
 
isn't there a binding on selected items?
 
8:24 AM
You would think that having my main model's "OnSelectedItemChanged" event listened to by only 4 listeners, rather than the 1000 it was earlier (including 996 pointless VMs that weren't even bound to any view!) would improve performance. It doesn't. Not much.
 
@AvnerShahar-Kashtan any ideas how i can do it?
 
@user1892991 Markus seems to have an idea
 
8:40 AM
@franssu still pretty new to wpf :/
I have a command binding for the button
 
yes and this command is located in your ViewModel right?
and that's also where your list bounded to the ItemSoursce of the ListView is located, yes?
 
one-way bound chat user
 
hehe
last friday I had a shot at helping (I think) @Mat'sMug with a grouped listbox, well now I have created something that might help: github.com/tb2johm/SimpleGroupedTreeList
BUT! I have never really used a model in my projects, can someone check if this is about the correct way?
it's a very simple project with just a model and a viewmodel
 
@user1892991 ListView, like ListBox, also doesn't have binding support for multiple SelectedItems, right?
First stop would be to write (that is, copy from the internet) a simple SelectedItemsBinding behavior, then just set SelectedItems = Items in your VM.
 
@AvnerShahar-Kashtan okay thanks, i'll look into it now and it does have support for multiple selected items
 
8:50 AM
So how about my model pattern? does it seem ok?
 
public ViewModel()
{
    Model model = Model.Instance;
 
mhmm
 
I would pass it by param
 
to the ViewModel?
 
yes
 
8:54 AM
from the View?
 
mmh yes, if the view is where you set up the sample
 
In MVVM the view is agnostic about the Model
 
should it really then create the model?
 
mmmh no it's not ?
model is agnostic of the view but not the other way around
anyways
here the "view" is where you seem to have decided to bootstrap the sample
when you did
<Window.Resources>
    <local:ViewModel x:Key="ViewModel"/>
</Window.Resources>
 
9:19 AM
What i mean is this, you don't handle the models from the view, you can bind to them though
 
9:31 AM
so where would you handle them in a small code sample like this ?
 
Ideally you request the model from a service
But in a sample like this where you want to demonstrate the capabilities of grouping, you can create all the sample data in ViewModel constructor, no need for singletons ( ever )
 
yes that's what I was thinking, there's no need for a model
 
9:47 AM
no absolutely not :) that was more because it was to help someone that probably had the data already. So I wanted to show him what I added with the viewmodel, and he could just use the data that he already had
however so you would add the model in the window resources and then add it as a parameter to the viewmodel in some way?
 
I would just get rid of it
 
ok, but let's say this was a large project, how would you create the model then?
I just have no experience with creating and using a model
 
that's a strange question to me because the model outlives the view / viewmodel
 
so where would you initiate it?
I mean somewhere it has to be created. in the app.xaml?
 
Person p = new Person();
 
9:58 AM
download the MVVM light visual studio project template and study the structure of the project
 
the model lives on its own, no one has to create it ??!?!?!??!
 
eh that would mean that the model only has static (public) functions?
 
why only ?
 
I'm sorry here, I have to say that to me, what a model really is is somewhat unclear (as you probably have gathered)
 
it has static functions, Create(), Recreate(), ...
 
10:02 AM
well if you don't have an instance of if you cant run instance functions on it
@NovitchiS (this? mvvmlight.codeplex.com)
 
model = pure domain objects
 
@Markus this is the framework, search for the project templates as well
 
I should really go a CS course...
 
so really asking who creates the model is like asking who creates the world ??!?!??!?!?!
 
well god did that, and it's not older than 4000 years :)
 
10:08 AM
:)
 
ok but if you have the patience... is the model (for example) a representation of a database?
 
This is a good question - who creates the models, and the answer is that the models are the Business Logic of your application, which should be accessed via services from your viewmodels, -> DataService.GetData();
 
well eric evans is to the model what god is to the world
 
Then you ask who creates the Services right ? then you go and inspect the MVVM project template :)
 
10:32 AM
        public ICommand btnSelectAll
        {
            get
            {
                if (_selectAllCommand == null)
                    _selectAllCommand = new RelayCommand(param => SelectAll(), param => CanSelectAll());

                return (_selectAllCommand);
            }
        }
i have a button bound to this command, i need to have some code in the CanSelectAll method in order to select the items in a listview right?
 
no
 
CanSelectAll is usually used to determine whether or not the button is enabled or not
 
oh mixed the CanSelectAll and SelectAll methods around
 
so yes you need to select all items in the SelectAll method
 
how can i go about selecting items in the listview?
still getting used to MVVM XD
@franssu @Markus any idea?
oh could i make the lv items a list and set isSelected to true?
 
10:45 AM
maybe. you have the SelectedItems property in the list right. Bind that to a list selectedList in the VM and in the command; insert all items in your list into the selectedList
 
okay i'll try that now, thanks
 
@Markus this is not possible straight away, you cannot bind to SelectedItems it is read only
 
aouch that's a shame...
 
will have to use a Behavior for this
 
whoa that's where I though in the towel.. just do it in code behind :)
 
11:01 AM
done!
thanks guys :)
 
 
2 hours later…
12:32 PM
hi guys, any1 datatemplate user here?
 
This question around here is something like asking hello humans do you breath air ? :)
 
hi, yes
 
:D
I have a strange problem
Im tryin to implement multilanguage stuff inside my solution using resx
Its working fine, but now i get an xaml exception all the time when binding to a resx staticresource inside a datatemplate
e.g. doing this for a textblock inside a datatemplate
Text="{Binding CameraModel, Source={StaticResource TranslationKC}}"
When im not in a datatemplate its working fin
so, humans do you breath air? xD
 
have you tried using DynamicResource
 
yes, it does not change anything. The TranslationKC is just a objectdataprovider so it doesnt matter if it is static or not
 
12:40 PM
what does the exception say ?
 
provide value on staticrecourceholder throws an exception
 
well, you might want to create a question on SO
 
The error says that the StaticResource markup extension did not find the TranslationKC key. Where is TranslationKC declared ?
 
12:59 PM
'morning all
 
Hello
 
hello Lynn
 
hello world
 
hello costa rica
 
jajajaja gracias
 
1:08 PM
I've been there :)
riding horses in la pampa :)
 
oohh really ? Costa Rica is Just beautiful
 
Nature with a big N :)
 
jejeje yes, I miss it :'(
 
1:54 PM
@NovitchiS Do you have a good example on this?
 
@Markus on translations ? not really, we use a custom markup extension that uses a .resx file, you can find lots of solutions on the web i think
 
No on the behavior
 
i think i used this solution in the past blog.functionalfun.net/2009/02/…
 
2:12 PM
Does anyone have any tips on debugging the measure -> arrange -> render flow? I have an adorner that's not re-rendering after one of its adorned elements' size has changed, and I'd rather not use a hacky solution where I just call _adorner.InvalidateVisual(); in OnRenderSizeChanged...
 
posted on September 03, 2015 by Nikolai Tillmann

This is a temporary post that was not deleted. Please delete this manually. (ab5e4ffa-2df1-475f-8aa8-cdbbdd0051ce - 3bfe001a-32de-4114-a6b4-4005b770f6d7)

 
@Jeremy Sorry, wish I could help :-/
@Feeds hahaha
 
@LynnCrumbling I know it's kind of XY-ish, but there's some odd code here I don't know how to reason about D:
 
I use adornerLayer.Update()
 
@franssu in OnRenderSizeChanged?
 
2:19 PM
where adornerLayer = AdornerLayer.GetAdornerLayer(adornedObject)
on LayoutUpdated
but I'm not sure it's the right way to do it
because I also have a flag to avoid an infinite loop :p
 
@franssu Hm. Well, this is a little nicer, I guess, but it's still quite hacky:
/// <summary>
/// Raises the <see cref="E:System.Windows.FrameworkElement.SizeChanged"/> event, using the specified information as part of the eventual event data.
/// </summary>
/// <param name="sizeInfo">Details of the old and new size involved in the change.</param>
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
    base.OnRenderSizeChanged(sizeInfo);
    var adornerLayer = AdornerLayer.GetAdornerLayer(this);
    if (adornerLayer != null)
    {
        adornerLayer.Update();
I'm quite perplexed that the RenderSize can change without the adorner doing anything about it. Shouldn't RenderSize have the AffectsRender metadata set always, and shouldn't that be sufficient for the adorner to rerender?
 
2:36 PM
if you find out, you tell us ;)
 
@franssu :)
 
posted on September 03, 2015 by Nikolai Tillmann

We have some exciting new developments to share – an update on our open source development, our ongoing cross-platform work, and more. Going forward, we will post everything around MSBuild and build tools in general here on the .NET blog. You can still check out the many interesting tips and tricks that we earlier posted on the MSBuild Team blog. MSBuild is now open source, and it is go

 
A-ha! I think I've found it.
 
got a question
how can I get the file path of an image that is a Resource in my project to be used like a file path?
I have tried several options:
/Soarfly Trip and Reporting System Administration Center;component/Resources/images/sfh.png"
pack://application:,,,/Soarfly Trip and Reporting System Aministration Center/Resources/images/sfh.png
and the image still won't show properly
 
2:52 PM
is the image in the same assembly ?
 
did you set its build action as resource ?
 
yup
I can access it through wpf
errr xaml
and it works
but I need the file path as a string
 
what do you mean ?
the path works in xaml ?
 
yes
 
2:54 PM
but not in code behind ?
 
yup
because I need the file path as a string to send it to a toastnotifications for the action center in windows 10/8.1
public void PushToastNotification(string Text)
{
XmlDocument toastxml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01);
XmlNodeList stringElemensts = toastxml.GetElementsByTagName("text");
stringElemensts[0].AppendChild(toastxml.CreateTextNode(Text));
String imagePath = System.Reflection.Assembly.GetExecutingAssembly().Location + "\\..\\..\\Resources\\images\\sfh.png";
XmlNodeList imageElements = toastxml.GetElementsByTagName("image");
imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;
that's the function that actually generates and pushes the notification
String imagePath
needs to have the file path of the resource
 
did you check System.Reflection.Assembly.GetExecutingAssembly().Location's value ?
 
yup
it's the folder of the exe file
that is compiled
 
you only have 1 dll ?
 
You cannot get a FilePath from a Resource, since the Resource is not a file, it is compiled into executable.
 
3:00 PM
not even the embedded location?
if that's the case, then how can I securely place my images in a location that users will NOT have easy access to
 
3:21 PM
and use something like
((XmlElement)toastImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/redWide.png")
i used the ms-appx syntax in windows phone apps
 
yes but does that work with resource files?
 
yes
 
and it will send multiples if needed?
or can I just replace what I have with an ms-appx string
 
yes you should try that :)
 
nope
didn't like it :(
the project has Resources\images\sfh.png
and that image is set as a Resource object
 
3:36 PM
I have a textbox in a user control, how can i make it readonly if it contains a specific string?
 
@user1892991 do you use mvvm?
 
@JoshMenzel yep
 
@user1892991 So bind your text property to a string in your viewmodel, then bind IsReadOnly(or it's ReadOnly, can't remember) property to a boolean in the viewmodel, then in the set constructor of the text property, do something like
if(value == yourvalue)
 
@JoshMenzel ahh i see!
thanks!
 
{
    TxtbxIsReadOnly=true;
}
else
{
    TxtbxIsReadOnly=false;
}
@user1892991 np
 
4:19 PM
well I guess I can just upload the image to my server, and at runtime, have it download the image
to the temp folder
that way, the user doesn't know where the image actually is
Annnddddd SORE!
My program supports the windows action center
 
@JoshMenzel You could just do a bool TxtbxIsReadOnly { get { return value == yourvalue); }}
Or, bind to the value in the ReadOnly attribute and write a converter.
 
@LynnCrumbling didn't think of that, that was for @user1892991
@LynnCrumbling Just got the windows action center supported :)
 
Very nice !
 
So Win10 has the concept of toasts.
Interesting.
That's what Android calls them.
 
4:29 PM
Yeah
I just did it through windows api calls
I just want to know how it works on windows 7
 
Do you test for OS major version before attempting them?
 
no I don't
Wouldn't windows 7 just ignore the calls?
 
Are you pInvoking them, or does the .net framework have them?
If you're pInvoking to DLLs that don't have support in 7, that'll crash you.
 
depends
the dlls it uses are the Microsoft.Windows.APICodePack
and Microsoft.Windows.APICodePack.Shell
as well as windows.winmd or some other file
(wasn't a dll but it's a .NET framework file that imports the namespace Windows)
but if it isn't supported by win 7, how would I keep one exe but check the os?
especially with the using statements?
 
What func call are you using?
I guess you're using the ToastNotification class
this msdn page documents it as only supported in win8 and up, but doesn't remark as to what happens if you attempt to call it in 7.
 
4:40 PM
well yeah since win8 is the lowest OS that supports the action center
 
@JoshMenzel The question is... does it fail gracefully, or do you need to test for OS Major before attempting to Toast...
 
hmm good question...how do I find out
I have no computers that have windows 7 on them that I can use to test, wait actually hang on 5mins I will go borrow my sisters laptop
 
anyone know any good articles on doing IoC in Wpf? gonna crack open the dependency injection in .net book again, otherwise
 
nvm I dont have access to a system with win7 on it
@LynnCrumbling do you?
 
Johan loves ninject
Their docs are good
Some feel it's overly complicated. If you ask in c#, you
will get responses akin too 'too complicated'
But it's more powerful and supports more cases than others.
If you don't need all of those edge cases, other DI frameworks might suit better
 
5:03 PM
@LynnCrumbling i guess i will just make a vm
virtual machine
 
I'm quite familiar with ninject, just looking for how to DI/IoC Wpf
 
@Maslow In my brief introduction, Johan made the constructor for my View get instaniate with the correct ViewModel parameter:
    public HomeView(HomeViewModel vm)
    {
        InitializeComponent();
        DataContext = vm;
    }
@Maslow ^ There's no code that instantiates the vm and passes it into the View constructor.
 
cool
 
It just works.
 
but doesn't that completely kill the designer? or do you have a default constructor just for that?
 
5:08 PM
And of course, you need this in the app codebehind:
public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
        this.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
        var kernel = new StandardKernel();
        var ninjectLoader = new NinjectLoader(kernel);
        var mainWindow = kernel.Get<MainWindow>();
        kernel.Bind<IMainWindowCallbacks>().To<MainWindow>();
        //kernel.Bind<IMessageRepository>().To<MessageRepository>().WithConstructorArgument("idparam", value);
The designer doesn't seem to care that there's no parameterless constructor.
 
Got an error with embedding my dlls as embedded resources
Set connectionid threw an exception
 
oh
 
5:26 PM
Is there a way to embed dlls into an exe?
I have tried doing from the obfuscator and it doesn't work
I have tried emedding the dlls and loading them as embedded resources and I get an xamlparserexception on setconnectionId
 
5:43 PM
@LynnCrumbling can you help me with this exception
{"[A]MahApps.Metro.Controls.Flyout cannot be cast to [B]MahApps.Metro.Controls.Flyout. Type A originates from 'MahApps.Metro, Version=1.1.3.162, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' in a byte array. Type B originates from 'MahApps.Metro, Version=1.1.3.162, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' in a byte array."}
 
5:53 PM
@LynnCrumbling nvm
@LynnCrumbling Got it working, turns out the dll for Mahapps.Metro.Resources is not needed, it just adds Icons.xaml to the project.
 
6:23 PM
Just saw this... glad you got it working :)
 
@LynnCrumbling Do you know of any free obfuscation tools?
@LynnCrumbling ConfuserEx doesn't work with Fody.Costura
 
@JoshMenzel Off the top of my head, only the the dot community editor of Obfusicator...
Is that still available?
It used to ship with vs...
 
from preemptive?
because that's the one in vs and all the features that actually work are grayed out and say purchase pro edition
and I am NOT going to spend $1195 on a shitty license that in reality should be free
 
6:57 PM
if it should be free, how come someone hasn't made their own free version yet?
 
it's called ConfuserEx
ILRepack
ILMerge
which don't support embedded assemblies as fody.costura does
i just need them to add obfuscation
 
7:35 PM
the other trouble is the .winmd file
it imports the Windows namespace
but it isn't like a regular dll file so obfuscators throw errors
 
Why obfuscate?
I mean, is it really worth it?
If I see obfuscated code, I'd be more tempted in finding out what you're hiding... not obfuscating it just makes it easier to browse the code
(I'm reading a reverse engineering book, so obfuscation is relevant to my interests)
 
This is to prevent people who are tech smart that want to decompile my software to use for illegal manners(i.e. server tampering, data spoofing/hacking). They would have access to the events for the database and could send bad data or delete everything from the database with the right combination of loops and events
because with the non profit I am writing this software for, people have gotten butthurt and tried to steal our documents, delete folders, etc...\
I am not going to let them do this to our server
 
 
1 hour later…
8:59 PM
@JoshMenzel I'm not sure how you limit what objects an api can work with, but I'd be relying on server-side security to limit what an api can do. In general, you should assume that every hacker understands your API fully and has access to a set of keys. Those keys should only be able to do as much damage as they have ownership over.
In my mind, an api key, or login, is synonymous with an account. Just because I can login to my gmail account doesn't mean I can delete everybody else's email.
In general, I worry about obfuscation for things like licensing.
But not network api security.
 
 
2 hours later…
11:00 PM
@JoshMenzel obfuscating won't do you any good. In the long run the OS is going to run the software as assembly instructions. A tech smart person will be able to debug your application during runtime and read the disassembly, then piece together whatever part of it they want.
Lynn is correct, and that's how many API providers work... by issuing api keys and serving only accredited applications using the specific key
 

« first day (1049 days earlier)      last day (3100 days later) »