|
No problems. Simply add a reply to one of his posts and link to the answer you gave there.
|
|
|
|
|
To me this sounds like the correct behaviour, by changing the text you have changed the property in your data context, and although you have not commited this to the database you are not refreshing the data from the database when re selecting the item. If you wish for any changed to be undone if you do not press the save button you may wish to consider calling
ObjectContext.Refresh(RefreshMode.StoreWins, WhatToRefresh);
The WhatToRefresh could be ObjectContext.NamesSourceTable, or to be more graceful you could just pass the previously slected item, i would guess that you call this when you change the slected item on the list. If you need a more full solution post a you code and i'll try to edit it for you.
|
|
|
|
|
We have one screen that has a datagrid. The datagrid contains the entire object (Parcel) and displays 3 fields in the display. The display is intended to be as such:
All parcels for a given site.
Highlight (or use a checkbox) to display those parcels that pertain to this record.
We can always do it the old way -- iterate thru the existing elements manually turning on the checkbox. But I prefer to keep this loosely bound. We've tried a few things but we both get brain freeze when coming up with the next approach.
Any suggestions on deploying this display of a query that intersects a subquery?
|
|
|
|
|
How about using a value converter[^]?
A converter would be called as each row binds to the datagrid.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Thanks for the suggestion but the passing of the subquery is where ValueConverter fails.
MSDN suggested that I implement an Interaction.Trigger and invoke a DelegateCommand.
I'm going to give that route a try.
Michael
|
|
|
|
|
Not sure why you need a sub-query. Can you not bind the checkbox to the site of the parcel, use a value converter passing in the current site as a converter parameter and return true if they are equal?
|
|
|
|
|
Not sure why you need a sub-query. Can you not bind the checkbox to the record id of the parcel, use a value converter passing in the current record id as a converter parameter and return true if they are equal?
|
|
|
|
|
A quick and dirty way would be to expose an IsSelected property on your parcel and bind to that.
C# has already designed away most of the tedium of C++.
|
|
|
|
|
I use an MVVM / custom control library that I wrote myself. Right now it works like this at a high level:
* all view models are derived from ViewModelBase
* I have an attached Type property called ViewModel that gets specified something like:
<Window ...
MyMVVMLib::ViewModelBase.ViewModel="{x:Type local:Test}">
.
.
</Window>
My library creates an instance of local:Test and sets the Window.DataContext equal to that instance.
* At this point, all ViewModels must have a default parameterless constructor
* ViewModelBase also has a static ServiceLocator
I have not really used Dependency Injection before, but it is my understanding that my current code looks like this:
public class Test : ViewModelBase
{
public Test()
{
ServiceLocator.GetService<IFoo1>();
ServiceLocator.GetService<IFoo2>();
}
}
vs. Dependency Injection which looks something like:
public class Test : ViewModelBase
{
public Test(IFoo1 foo1, IFoo2 foo2)
{
}
}
at some point early in the start up, you are supposed to register the interface <-> implementation class mappings?
So if I want to add DI support to my MVVM lib, it is my understanding that the ViewLocator needs to go through the params in the constructor and match up the interfaces with the classes that you registered.
I am **NOT** interested in using a DI lib that somebody else wrote like Unity, etc. I am interested in knowing how they work and implementing my own.
Seems like the requirement is that you have a single public constructor? Some libs I have seen add a custom attribute like [DependencyInjection] or [Ninject] to the one constructor that you want the DI to happen on? What is the best approach?
Are these libs using reflection to go through the constructor params? Or some other cool mechanism for which I am unaware?
I assume there is some kind of caching going on? Like, it only needs to go through the reflection once and then caches the interfaces and the order of which they are passed in?
Last question for now... seems like ServiceLocator, you pass in the type and a class instance to register, but in DI, you pass in an interface type and a class instance type?
|
|
|
|
|
I thought Unity was open source - why dont you have a look at the source code itself?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Thanks, I took a look at the code. Its still not very clear how it works. It doesn't seem to use reflection for example to determine parameters. Seems like it uses some other unknown (to me) mechanism.
|
|
|
|
|
|
Jesus... I can barely read that article . The English on it is so poor! The guy is just randomly making up words as he goes along it seems.
Anyways, thanks for the link... it seems to be LEADING to DI, but its not DI.
He does something like this:
public Gadget() : this(Container.Instance.GetImplementerOf<ILogger>())
{
}
thats kind of manual DI which is not really DI IMO. Its more Service Locator.
EDIT: I also saw part 2 of his blog where he just added XML support to the container. Still not really DI since he is still manually resolving the dependencies which is more Service Locator as I mentioned above. I mean, the pattern is sort of DI with the interfaces in the constructor, but then he uses manual resolution whereas true DI is automatic.
|
|
|
|
|
Yeah, I Agree,
that example he uses is a bit dodgy but I can understand why he didn't want to write an entire DI engine for a beginners tutorial. Anyway, Like I say, I found it was an ok place to start before moving on to other stuff.
|
|
|
|
|
i hava a Datagrid with Checkbox as one of the columns in it. Need to trap the click event & accordingly enable/disable buttons on my WPF Page (xaml).am using MVVM architecture.
Following is the code:
<DataGrid AutoGenerateColumns="False" CanUserAddRows="False"
Name="grdRequestTemplate" VerticalAlignment="Top" Width="Auto"
ItemsSource="{Binding FetchTemplateList}"
SelectedItem="{Binding Path=FetchTemplateElement}" RowDetailsVisibilityMode="VisibleWhenSelected"
ColumnHeaderStyle="{StaticResource columnHeaderStyle}" RowStyle="{StaticResource rowStyle}"
CellStyle="{StaticResource cellStyle}" GridLinesVisibility="None"
RowHeaderStyle="{StaticResource rowHeaderStyle}" IsReadOnly="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="TemplateID" HeaderStyle="{StaticResource WrappedColumnHeaderStyle}"
Visibility="Hidden" Binding="{Binding TemplateID}" MinWidth="50" />
<DataGridTextColumn Header="TemplateUserMappingId" Visibility="Hidden" Binding="{Binding TemplateUserMappingId}" MinWidth="50" />
<DataGridCheckBoxColumn Header="#" Binding="{Binding Check}" />
<DataGridTemplateColumn Header="#2">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=ChkBoxClickCommand}" Checked="CheckBox_Checked" Click="CheckBox_Click" HorizontalAlignment="Center" VerticalAlignment="Center">
</CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="User ID" HeaderStyle="{StaticResource WrappedColumnHeaderStyle}"
Binding="{Binding UserLabelId}" MinWidth="150" IsReadOnly="True" />
<DataGridTextColumn Header="Template Name" HeaderStyle="{StaticResource WrappedColumnHeaderStyle}"
Binding="{Binding Name}" Width="*" IsReadOnly="True" />
<DataGridTextColumn Header="Application" HeaderStyle="{StaticResource WrappedColumnHeaderStyle}"
Binding="{Binding TypeLabel}" MinWidth="100" IsReadOnly="True" />
<DataGridTextColumn Header="Date Requested" HeaderStyle="{StaticResource WrappedColumnHeaderStyle}"
Binding="{Binding RequestedOnDate}" IsReadOnly="True">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
i want to register the click event in the ViewModel.cs but how do i call the same from my xaml.cs page? what code do i need to write?
Appreciate an early response.
With Warm Regards,
Yogesh Jamkhindikar
|
|
|
|
|
Just a thought, have you debugged through this value change and see when it fires, handle the VM values from the change of the property.
IsChecked="{Binding Path=ChkBoxClickCommand}"
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Good Day All
i have an application that i use to test my example. i am creating a Cookie in Silverlight and access the Cookie in asp.net. In my example application works fine. The code for creating a Cookie is like this
private void SetCookies(string name, string value)
{
string code = string.Format("document.getElementById('myIFrame').contentWindow.SetCookie('{0}','{1}')", name, value);
HtmlPage.Window.Eval(code);
}
and in my Page load of the Silverlight Page i have this
HtmlElement iframe = (HtmlElement)radHtmlPlaceholder1.HtmlPresenter.Children[0];
iframe.SetAttribute("id", "myIFrame");
I am using it this way because i want to access a Cookie or a Value from Silverlight in asp.net. The Element "RadhtmlplaceHolder1" is a telerik control that is being used as described here [LINK]http://blogs.telerik.com/kirilstanoev/posts/11-05-10/reading_writing_cookies_with_htmlplaceholder_for_silverlight.aspx[/LINK]
i will not go to the aspx page where the Cookie is being accessed, but the problem comes when setting it in this line
HtmlPage.Window.Eval(code);
Attempted to read or write protected memory. This is often an indication that other memory is corrupt
Please note that this is on a SilverlightChild Window
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
<Window>
<Window.Resources>
<ContextMenu ... >
<Button Command={Binding ... } />
</ContextMenu>
</Window.Resources>
</Window>
I'm trying to bind the button command to a property in the window. Window.DataContext is set. I've also tried Binding ElementName=windowName, Path=propName, but no luck.
|
|
|
|
|
Yes, but keep in mind that an object in the Resources section isn't actually part of the logical tree, and hence, has nothing to bind to. ElementName bindings won't work either, in this situation.
If you use a StaticResource reference to pull it into the tree, then it can use its parent for the DataContext... Except ContextMenus don't go into the tree at all.
You might try binding the DataContext of the ContextMenu to its PlacementTarget, and make sure that's set when you display it. If that fails, you might have to hook the menu's events to set that, or set the DataContext directly, when it's opened.
|
|
|
|
|
Thanks for the info...
Yeah, I just looped through the items when I open the menu and set the Command properties there. Kind of cheezy, but oh well....
|
|
|
|
|
Hi,
How to identify/find that silverlight is installed in client browser from server side.
Regards
Bhavin
|
|
|
|
|
I don't think you can. It doesn't add anything to the user agent (at least it didn't used to), so the only way you could tell is by writing something that does a client side check and then reports this back to the server.
|
|
|
|
|
You would need to run some sort of a script on the client that informs the server if there is a version installed.
If you want to do this via silverlight, the silverlight client will need to communicate with a web service where the version can be a parameter.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi all,
I am developing an image manipulation application using Silverlight 4.0.
I am using Nokola's adorner control to rotate image on canvas and its working perfectly.
But the problem is that after rotation when I merge this rotated image with my Main Image (that is on canvas and is an Image Control, and I am doing this with WritableBitmap),
it is not merging at what place it was rotated. I have searched a lot but no success.
I have linke that will explain more : http://stackoverflow.com/questions/581837/wpf-getting-new-coordinates-after-a-rotation[^], but still i am not able to do this...
Please help guys.
Thanx & Regards
Suresh
Be an Eagle, Sky is Yours.
|
|
|
|
|
I took a look at the link and it seemed to explain how to do exactly what you are trying to do - but you say you are not able to do this - I guess my question is, why not?
|
|
|
|