none
WPF TextBox binding not working after (window+L) and login in Wondows10 RRS feed

  • Question

  • Hi,

    I have created a small application where a TextBox is clear on ButtonClick. (MVVM binding)

    On running application, its working fine.

    After (Window+L) and login, TextBox binding stops working.

    After debugging, TextBox value is set, but its not refreshed on UI.

    Please help me out to resolve this issue.

    Thanks in advance.

    Athar Imam

    <TextBox Name="ResponseText" IsReadOnly="False" TextWrapping="WrapWithOverflow" ScrollViewer.VerticalScrollBarVisibility="Auto" Text="{Binding ResponseText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, IsAsync=true }" 
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="True" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" BorderThickness="1" />
    • Edited by Athar Imam Monday, December 2, 2019 2:05 PM
    Monday, December 2, 2019 2:04 PM

Answers

  • Hi,

    I don't know what effect ResourceDictionary has on the program. But will the binding not working you said be caused by the UI stuck?You can try to add the following code in the app.xaml.cs:

    protected override void OnStartup(StartupEventArgs e)
    {
        RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
    }

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Athar Imam Thursday, December 5, 2019 7:57 AM
    Thursday, December 5, 2019 1:42 AM
    Moderator

All replies

  • Hi,

    I tried to log in after pressing Window + L, but the TextBox can still be updated normally. Do you think my code is different from yours?

      public partial class MainWindow : Window
        {
            MyTest mt = new MyTest();
            public MainWindow()
            {
                InitializeComponent();
                this.DataContext = mt;
                
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                mt.ResponseText = "test2";
            }
        }
        public class MyTest : INotifyPropertyChanged
        {
            private string _ResponseText="test1";
    
            public string ResponseText
            {
                get
                {
                    return _ResponseText;
                }
                set
                {
                    _ResponseText = value;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ResponseText"));
                }
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
    
          
        }

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 3, 2019 1:53 AM
    Moderator
  • Hi,

    I have applied below theme.

    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
                    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />

    After removing above theme, all works fine.

    Tuesday, December 3, 2019 10:00 AM
  • Hi,

    I am glad you have got your solution,please mark it as answer.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 4, 2019 1:10 AM
    Moderator
  • Hi,

    I can't remove above themes, as its applied in whole application.

    Please suggest another solution.

    Thanks,

    Athar Imam

    Wednesday, December 4, 2019 8:38 AM
  • Hi,

    I don't know what effect ResourceDictionary has on the program. But will the binding not working you said be caused by the UI stuck?You can try to add the following code in the app.xaml.cs:

    protected override void OnStartup(StartupEventArgs e)
    {
        RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
    }

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Athar Imam Thursday, December 5, 2019 7:57 AM
    Thursday, December 5, 2019 1:42 AM
    Moderator