Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从承载的wpf浏览器应用程序中删除按钮高亮显示_C#_Css_Asp.net Mvc_Wpf_Mvvm - Fatal编程技术网

C# 从承载的wpf浏览器应用程序中删除按钮高亮显示

C# 从承载的wpf浏览器应用程序中删除按钮高亮显示,c#,css,asp.net-mvc,wpf,mvvm,C#,Css,Asp.net Mvc,Wpf,Mvvm,问题是: 当托管此功能性最低的代码时,在导航或刷新页面时,表单上的第一个按钮将以蓝色内边框突出显示。从控件中删除边框将完全删除内部边框,但是我们要求控件上有边框 好的,这将是一个糟糕的结果,所以我将发布两个项目的全部最小功能代码,一个MVC和一个WPF 项目1-MVC ~/Views/Shared/\u Layout.cshtml <!DOCTYPE html> <html> <head> <meta http-equiv="X-

问题是:

当托管此功能性最低的代码时,在导航或刷新页面时,表单上的第一个按钮将以蓝色内边框突出显示。从控件中删除边框将完全删除内部边框,但是我们要求控件上有边框

好的,这将是一个糟糕的结果,所以我将发布两个项目的全部最小功能代码,一个MVC和一个WPF

项目1-MVC ~/Views/Shared/\u Layout.cshtml

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
        <style>
            .scrollUp, .scrollDown {
                width: 110px;
                height: 110px;
                background-color: black;
                border-radius: 55px;
                color: white;
                font-size: 1.6em;
                background: linear-gradient(120deg, #404040, black);
            }
        </style>

    </head>
    <body>
        @RenderBody()
        @RenderSection("footer", false)

        <button class="scrollUp">Page<br />Up</button>
        <button class="scrollDown">Page Down</button>
    </body>
</html>
@{

    ViewBag.Title = "Kiosk Online Ordering";
}

Birds
~/Controllers/Home/HomeController.cs

using System.Web.Mvc;
namespace Kiosk.Web.Controllers
{
    public class HomeController : Controller
    {
        public ViewResult Index()
        {
            return View();
        }
    }
}
using System;
using System.Windows;
using System.Windows.Controls;
using Store.Kiosk.Services;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindowView : Window
    {
        private IWebKioskConfigurationService _webKioskConfigurationService;

        public MainWindowView()
        {
            _webKioskConfigurationService = new WebKioskConfigurationService();
            //_webKioskConfigurationService = webKioskConfigurationService;

            DataContext = new KioskWebBrowserViewModel
            {
                WebBrowserControl = new WebBrowser { Source = _webKioskConfigurationService.GetDefaultUri() }
            };
            InitializeComponent();
        }
    }
}
using System;
using System.Windows.Controls;

namespace KK.Store.Kiosk.Standalone.ViewModels
{
// ReSharper disable ClassNeverInstantiated.Global
    public class DesignKioskWebBrowserViewModel : KioskWebBrowserViewModel
// ReSharper restore ClassNeverInstantiated.Global
    {
        public DesignKioskWebBrowserViewModel()
        {
            WebBrowserControl = new WebBrowser { Source = new Uri("http://www.google.com", UriKind.Absolute) };
        }
    }
}
using System;
using System.Windows.Controls;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.ViewModels
{
    public class KioskWebBrowserViewModel : ViewModelBase
    {
        public KioskWebBrowserViewModel()
        {
        }
        private WebBrowser _webBrowserControl;

        public WebBrowser WebBrowserControl
        {
            get { return _webBrowserControl; }
            set { SetValue(ref _webBrowserControl, value); }
        }
    }
}
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Store.Kiosk.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private bool _isVisible = true;

        public bool IsVisible
        {
            get { return _isVisible; }
            set { SetValue(ref _isVisible, value); }
        }


        [STAThread]
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        [STAThread]
        ~ViewModelBase()
        {
            Dispose(false);
        }

        protected virtual void Dispose(bool disposing)
        {
        }

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        protected void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (Equals(value, field)) return;

            field = value;

            OnPropertyChanged(propertyName);
        }
    }
}
using System;

namespace Store.Kiosk.Services
{
    public interface IWebKioskConfigurationService
    {
        Uri GetDefaultUri();
    }
}
using System;

namespace Store.Kiosk.Services
{
    public class WebKioskConfigurationService : IWebKioskConfigurationService
    {
        public Uri GetDefaultUri()
        {
            return new Uri("http://localhost/{YourKioskWebsiteUrl}", UriKind.Absolute);
        }
    }
}
项目2-WPF主机 Views/MainWindowView.xaml

<Window x:Class="Store.Kiosk.Views.MainWindowView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:viewModels="clr-namespace:Store.Kiosk.ViewModels"
        mc:Ignorable="d"
        Title="MainWindow" Height="1024" Width="1280" d:DataContext="{d:DesignInstance viewModels:DesignKioskWebBrowserViewModel, IsDesignTimeCreatable=True}"
        ResizeMode="NoResize" WindowStyle="None" WindowStartupLocation="CenterScreen">
    <ContentControl Content="{Binding WebBrowserControl}"/>
</Window>
ViewModels/kioskwebrowserviewmodel.cs

using System.Web.Mvc;
namespace Kiosk.Web.Controllers
{
    public class HomeController : Controller
    {
        public ViewResult Index()
        {
            return View();
        }
    }
}
using System;
using System.Windows;
using System.Windows.Controls;
using Store.Kiosk.Services;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindowView : Window
    {
        private IWebKioskConfigurationService _webKioskConfigurationService;

        public MainWindowView()
        {
            _webKioskConfigurationService = new WebKioskConfigurationService();
            //_webKioskConfigurationService = webKioskConfigurationService;

            DataContext = new KioskWebBrowserViewModel
            {
                WebBrowserControl = new WebBrowser { Source = _webKioskConfigurationService.GetDefaultUri() }
            };
            InitializeComponent();
        }
    }
}
using System;
using System.Windows.Controls;

namespace KK.Store.Kiosk.Standalone.ViewModels
{
// ReSharper disable ClassNeverInstantiated.Global
    public class DesignKioskWebBrowserViewModel : KioskWebBrowserViewModel
// ReSharper restore ClassNeverInstantiated.Global
    {
        public DesignKioskWebBrowserViewModel()
        {
            WebBrowserControl = new WebBrowser { Source = new Uri("http://www.google.com", UriKind.Absolute) };
        }
    }
}
using System;
using System.Windows.Controls;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.ViewModels
{
    public class KioskWebBrowserViewModel : ViewModelBase
    {
        public KioskWebBrowserViewModel()
        {
        }
        private WebBrowser _webBrowserControl;

        public WebBrowser WebBrowserControl
        {
            get { return _webBrowserControl; }
            set { SetValue(ref _webBrowserControl, value); }
        }
    }
}
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Store.Kiosk.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private bool _isVisible = true;

        public bool IsVisible
        {
            get { return _isVisible; }
            set { SetValue(ref _isVisible, value); }
        }


        [STAThread]
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        [STAThread]
        ~ViewModelBase()
        {
            Dispose(false);
        }

        protected virtual void Dispose(bool disposing)
        {
        }

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        protected void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (Equals(value, field)) return;

            field = value;

            OnPropertyChanged(propertyName);
        }
    }
}
using System;

namespace Store.Kiosk.Services
{
    public interface IWebKioskConfigurationService
    {
        Uri GetDefaultUri();
    }
}
using System;

namespace Store.Kiosk.Services
{
    public class WebKioskConfigurationService : IWebKioskConfigurationService
    {
        public Uri GetDefaultUri()
        {
            return new Uri("http://localhost/{YourKioskWebsiteUrl}", UriKind.Absolute);
        }
    }
}
ViewModels/ViewModelBase.cs

using System.Web.Mvc;
namespace Kiosk.Web.Controllers
{
    public class HomeController : Controller
    {
        public ViewResult Index()
        {
            return View();
        }
    }
}
using System;
using System.Windows;
using System.Windows.Controls;
using Store.Kiosk.Services;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindowView : Window
    {
        private IWebKioskConfigurationService _webKioskConfigurationService;

        public MainWindowView()
        {
            _webKioskConfigurationService = new WebKioskConfigurationService();
            //_webKioskConfigurationService = webKioskConfigurationService;

            DataContext = new KioskWebBrowserViewModel
            {
                WebBrowserControl = new WebBrowser { Source = _webKioskConfigurationService.GetDefaultUri() }
            };
            InitializeComponent();
        }
    }
}
using System;
using System.Windows.Controls;

namespace KK.Store.Kiosk.Standalone.ViewModels
{
// ReSharper disable ClassNeverInstantiated.Global
    public class DesignKioskWebBrowserViewModel : KioskWebBrowserViewModel
// ReSharper restore ClassNeverInstantiated.Global
    {
        public DesignKioskWebBrowserViewModel()
        {
            WebBrowserControl = new WebBrowser { Source = new Uri("http://www.google.com", UriKind.Absolute) };
        }
    }
}
using System;
using System.Windows.Controls;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.ViewModels
{
    public class KioskWebBrowserViewModel : ViewModelBase
    {
        public KioskWebBrowserViewModel()
        {
        }
        private WebBrowser _webBrowserControl;

        public WebBrowser WebBrowserControl
        {
            get { return _webBrowserControl; }
            set { SetValue(ref _webBrowserControl, value); }
        }
    }
}
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Store.Kiosk.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private bool _isVisible = true;

        public bool IsVisible
        {
            get { return _isVisible; }
            set { SetValue(ref _isVisible, value); }
        }


        [STAThread]
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        [STAThread]
        ~ViewModelBase()
        {
            Dispose(false);
        }

        protected virtual void Dispose(bool disposing)
        {
        }

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        protected void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (Equals(value, field)) return;

            field = value;

            OnPropertyChanged(propertyName);
        }
    }
}
using System;

namespace Store.Kiosk.Services
{
    public interface IWebKioskConfigurationService
    {
        Uri GetDefaultUri();
    }
}
using System;

namespace Store.Kiosk.Services
{
    public class WebKioskConfigurationService : IWebKioskConfigurationService
    {
        public Uri GetDefaultUri()
        {
            return new Uri("http://localhost/{YourKioskWebsiteUrl}", UriKind.Absolute);
        }
    }
}
服务/WebKioskConfigurationService.cs

using System.Web.Mvc;
namespace Kiosk.Web.Controllers
{
    public class HomeController : Controller
    {
        public ViewResult Index()
        {
            return View();
        }
    }
}
using System;
using System.Windows;
using System.Windows.Controls;
using Store.Kiosk.Services;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindowView : Window
    {
        private IWebKioskConfigurationService _webKioskConfigurationService;

        public MainWindowView()
        {
            _webKioskConfigurationService = new WebKioskConfigurationService();
            //_webKioskConfigurationService = webKioskConfigurationService;

            DataContext = new KioskWebBrowserViewModel
            {
                WebBrowserControl = new WebBrowser { Source = _webKioskConfigurationService.GetDefaultUri() }
            };
            InitializeComponent();
        }
    }
}
using System;
using System.Windows.Controls;

namespace KK.Store.Kiosk.Standalone.ViewModels
{
// ReSharper disable ClassNeverInstantiated.Global
    public class DesignKioskWebBrowserViewModel : KioskWebBrowserViewModel
// ReSharper restore ClassNeverInstantiated.Global
    {
        public DesignKioskWebBrowserViewModel()
        {
            WebBrowserControl = new WebBrowser { Source = new Uri("http://www.google.com", UriKind.Absolute) };
        }
    }
}
using System;
using System.Windows.Controls;
using Store.Kiosk.ViewModels;

namespace Store.Kiosk.ViewModels
{
    public class KioskWebBrowserViewModel : ViewModelBase
    {
        public KioskWebBrowserViewModel()
        {
        }
        private WebBrowser _webBrowserControl;

        public WebBrowser WebBrowserControl
        {
            get { return _webBrowserControl; }
            set { SetValue(ref _webBrowserControl, value); }
        }
    }
}
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Store.Kiosk.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private bool _isVisible = true;

        public bool IsVisible
        {
            get { return _isVisible; }
            set { SetValue(ref _isVisible, value); }
        }


        [STAThread]
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        [STAThread]
        ~ViewModelBase()
        {
            Dispose(false);
        }

        protected virtual void Dispose(bool disposing)
        {
        }

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        protected void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (Equals(value, field)) return;

            field = value;

            OnPropertyChanged(propertyName);
        }
    }
}
using System;

namespace Store.Kiosk.Services
{
    public interface IWebKioskConfigurationService
    {
        Uri GetDefaultUri();
    }
}
using System;

namespace Store.Kiosk.Services
{
    public class WebKioskConfigurationService : IWebKioskConfigurationService
    {
        public Uri GetDefaultUri()
        {
            return new Uri("http://localhost/{YourKioskWebsiteUrl}", UriKind.Absolute);
        }
    }
}
因此,如果您在没有兼容模式的情况下安装了IE9+,这将导致出现两个按钮,其中一个按钮的内边框为蓝色。我已尝试从:hover、:active、:focus、:::-moz focus-internal中删除边框,但它们似乎都不起作用。只要我将边框重新添加到按钮,蓝色的内边框就会返回。有人对这个问题足够熟悉吗

我正在运行IE11