I changed the SelectedItem via a Binding. Now how do I move it into view without code-behind? - wpfdatagrid

I've got a DataGrid with a Two-Way Binding on SelectedItem. I can change the SelectedItem in my ViewModel, but the DataGrid won't ScrollIntoView automatically.
Is there a way to do this without using a code-behind event handler that calls ScrollIntoView(SelectedItem), or should I just give in and use a little code-behind?

Check http://www.codeproject.com/Tips/125583/ScrollIntoView-for-a-DataGrid-when-using-MVVM.aspx

Related

WPF - Bind command declaratively to code behind when different from the datacontext

I'm not so great with WPF, so I am looking at a WPF control that someone else has created which has a datacontext set to another class, but also has tons of code in the code-behind on the actual control.
I need to create a context menu command that binds to a method inside of the code behind, not the actual datacontext of the control. I know how to create the context menu, just looking for how to bind to code behind when using another datacontext on the control.
Thanks!

Is there a 'UpdateSourceTrigger' equivalent in Xamarin Forms?

I am using Xamarin.Forms, with my view created fully in XAML. I am also using Xamarin.Forms.Labs.
I have bound an EntryCell to a property like so:
<EntryCell Label="Name:" Text="{Binding Name, Mode=TwoWay}" />
The page has a 'Save' ToolBarItem which saves the property to a database.
The issue I have is that the Name property is only updated when the entry cell loses focus after the user changes the text. Clicking the ToolBarItem does not change focus and therefore the property is not updated before being saved.
I would like the property to be updated with every key press from the user. I know of 'UpdateSourceTrigger' for Silverlight, but I can't find an equivalent way to do this in Xamarin Forms?
There is no equivalent for UpdateSourceTrigger in Xamarin.Forms
There doesn't seem to be a xamarin equivalent to UpdateSourceTrigger. I have had success by removing the SetProperty call from the bound property so that the property changed does not fire, and then using EntryUnfocused to trigger an explicit PropertyChanged event.

Accessing Silverlight Text Property in Loaded Event

I am subscribed to the Loaded event of a Silverlight TextBox. I would like to access the Text property in this event. It works properly when I directly set the text, but when I am binding the Text property it is always empty. Is there way to do this without subscribing to the LayoutUpdated event instead?
please try using TextChanged property instead. :)

Force Silverlight DataForm into Normal mode

I'm trying to use the DataForm to display data. The CurrentItem is bound to a property on my ViewModel. The property it is bound to is a simple poco. I've created a custom readonly template. Everything works fine except I can't figure out how to make the DataForm appear "Enabled" or in the Normal state. The data isn't editable, it's displayed as readonly.
The only way I've been able to get it to display in the Normal state was to edit the template and set the Opacity to 100% for the DisabledVisual border.
Is there a better way to do this or use the DataForm for displaying data that isn't editable but still appear enabled?
This fixed it: jedwards14.blogspot.com/2011/02/silerlight-data-forms-with.html. I do have a busy indicator, apparently this is still and issue: silverlight.codeplex.com/workitem/4729

How does the tooltip control enhance all controls on the form with a new property?

When answering another question I started to wonder how I could Add new properties to all controls in a form just like the ToolTip-control does.
For example I could use that to Add a "IsDirty"-flag to all textboxes just by adding the component to the form and it would handle this for every textbox.
When adding the tooltip-control to the form all controls magically gets a new property "Tooltip on tooltip1" that can be set both programatically and in design view.
I want to be able to do my own enhancer like that.
It's an Extender Provider.