Click here to Skip to main content
15,860,844 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF TextBox Handle Data Pasted In Pin
Richard Deeming14-Apr-21 22:50
mveRichard Deeming14-Apr-21 22:50 
GeneralRe: WPF TextBox Handle Data Pasted In Pin
Kevin Marois15-Apr-21 5:49
professionalKevin Marois15-Apr-21 5:49 
QuestionFormat Percentage Pin
Kevin Marois13-Apr-21 9:16
professionalKevin Marois13-Apr-21 9:16 
AnswerRe: Format Percentage Pin
Richard Deeming13-Apr-21 22:36
mveRichard Deeming13-Apr-21 22:36 
GeneralRe: Format Percentage Pin
Kevin Marois14-Apr-21 7:42
professionalKevin Marois14-Apr-21 7:42 
QuestionAvalonEdit Sytax Highlighting for XAML files? Pin
#realJSOP5-Apr-21 8:57
mve#realJSOP5-Apr-21 8:57 
AnswerRe: AvalonEdit Sytax Highlighting for XAML files? Pin
Richard Deeming6-Apr-21 0:22
mveRichard Deeming6-Apr-21 0:22 
QuestionRevert Property Change Pin
Kevin Marois5-Apr-21 7:20
professionalKevin Marois5-Apr-21 7:20 
I have a ComboBox bound to a list of objects. When the user selects one, I want to warn the user. If they select No to my warning, I want to prevent the change.

The code in the VM's property setter runs, and it even appears to set SelectedVendor back to what it was, but in the UI it doesn't revert.
XAML
<ComboBox Grid.Row="0"
            Grid.Column="1"
            ItemsSource="{Binding JobVendors, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
            SelectedItem="{Binding SelectedVendor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
            Style="{StaticResource localComboStyle}"/>
ViewModel
private CompanyHeaderEntity _SelectedVendor;
public CompanyHeaderEntity SelectedVendor
{
    get { return _SelectedVendor; }
    set
    {
        var currentVendor = _SelectedVendor;

        if (_SelectedVendor != value)
        {
            bool okToChange = true;

            if (!_isLoading &&
                PurchaseOrderHeader.PurchaseOrderItems != null &&
                PurchaseOrderHeader.PurchaseOrderItems.Count > 0)
            {
                var message = "Changing vendors will remove all selected items. Continue?";
                okToChange = MessageBox.Show(message, "Change Vendor", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;

                if (okToChange)
                {
                    PurchaseOrderHeader.PurchaseOrderItems.Clear();
                }
            }

            if (okToChange)
            {
                _SelectedVendor = value;
                RaisePropertyChanged("SelectedVendor");

                VendorSelected();
            }
            else
            {
                if (currentVendor != null)
                {
                    _SelectedVendor = currentVendor;
                }
            }
        }
    }
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 5-Apr-21 14:37pm.

AnswerRe: Revert Property Change Pin
#realJSOP5-Apr-21 8:55
mve#realJSOP5-Apr-21 8:55 
QuestionUI not updating Pin
#realJSOP28-Mar-21 3:52
mve#realJSOP28-Mar-21 3:52 
AnswerRe: UI not updating Pin
Pete O'Hanlon28-Mar-21 6:10
subeditorPete O'Hanlon28-Mar-21 6:10 
GeneralRe: UI not updating Pin
#realJSOP28-Mar-21 6:40
mve#realJSOP28-Mar-21 6:40 
AnswerRe: UI not updating Pin
Richard Deeming28-Mar-21 22:20
mveRichard Deeming28-Mar-21 22:20 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 2:59
mve#realJSOP29-Mar-21 2:59 
AnswerRe: UI not updating Pin
Gerry Schmitz29-Mar-21 9:15
mveGerry Schmitz29-Mar-21 9:15 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 10:38
mve#realJSOP29-Mar-21 10:38 
GeneralRe: UI not updating Pin
Gerry Schmitz29-Mar-21 11:24
mveGerry Schmitz29-Mar-21 11:24 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 12:07
mve#realJSOP29-Mar-21 12:07 
GeneralRe: UI not updating Pin
Gerry Schmitz29-Mar-21 12:19
mveGerry Schmitz29-Mar-21 12:19 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 23:33
mve#realJSOP29-Mar-21 23:33 
GeneralRe: UI not updating Pin
Richard Deeming29-Mar-21 21:36
mveRichard Deeming29-Mar-21 21:36 
GeneralRe: UI not updating Pin
#realJSOP29-Mar-21 23:42
mve#realJSOP29-Mar-21 23:42 
GeneralRe: UI not updating Pin
Richard Deeming30-Mar-21 0:05
mveRichard Deeming30-Mar-21 0:05 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 5:12
mve#realJSOP30-Mar-21 5:12 
GeneralRe: UI not updating Pin
#realJSOP30-Mar-21 12:14
mve#realJSOP30-Mar-21 12:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.