Click here to Skip to main content
14,920,935 members
Home / Discussions / WPF
   

WPF

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 3:09
cofounderChris Maunder16-Jul-09 3:09 
PinnedHow to get an answer to your question PinPopular
Chris Maunder16-Jul-09 3:05
cofounderChris Maunder16-Jul-09 3:05 
QuestionProblem Setting Focus Pin
Kevin Marois24-May-21 9:39
professionalKevin Marois24-May-21 9:39 
AnswerRe: Problem Setting Focus Pin
Richard Deeming24-May-21 21:56
mveRichard Deeming24-May-21 21:56 
QuestionImpossible to override a value in an animation located in a style? Pin
Mc_Topaz20-May-21 6:51
MemberMc_Topaz20-May-21 6:51 
AnswerRe: Impossible to override a value in an animation located in a style? Pin
Gerry Schmitz20-May-21 8:08
mveGerry Schmitz20-May-21 8:08 
QuestionApp Security Behavior Pin
Kevin Marois20-May-21 6:09
professionalKevin Marois20-May-21 6:09 
QuestionOverride a value in base style's resource Pin
Mc_Topaz20-May-21 2:45
MemberMc_Topaz20-May-21 2:45 
AnswerRe: Override a value in base style's resource Pin
Richard Deeming20-May-21 4:33
mveRichard Deeming20-May-21 4:33 
GeneralRe: Override a value in base style's resource Pin
Mc_Topaz20-May-21 6:00
MemberMc_Topaz20-May-21 6:00 
QuestionApply TextBlock Captions at Runtime Pin
Kevin Marois14-May-21 9:34
professionalKevin Marois14-May-21 9:34 
AnswerRe: Apply TextBlock Captions at Runtime Pin
Peter_in_278014-May-21 13:36
professionalPeter_in_278014-May-21 13:36 
GeneralRe: Apply TextBlock Captions at Runtime Pin
Kevin Marois14-May-21 13:42
professionalKevin Marois14-May-21 13:42 
GeneralRe: Apply TextBlock Captions at Runtime Pin
Pete O'Hanlon14-May-21 23:51
mvePete O'Hanlon14-May-21 23:51 
AnswerRe: Apply TextBlock Captions at Runtime Pin
Mycroft Holmes15-May-21 12:25
professionalMycroft Holmes15-May-21 12:25 
GeneralRe: Apply TextBlock Captions at Runtime Pin
Gerry Schmitz16-May-21 11:17
mveGerry Schmitz16-May-21 11:17 
QuestionWPF TextBox Handle Data Pasted In Pin
Kevin Marois14-Apr-21 8:29
professionalKevin Marois14-Apr-21 8:29 
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
mva#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.

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.