小编Tan*_*Tan的帖子

为什么我不能将DataTrigger添加到控件的Triggers集合中?

为什么我不能像这样编码

<Border Width="130" Height="70">
    <Border.Triggers>
        <DataTrigger Binding="{Binding Path=CurrentStatus}" Value="0">
            <Setter Property="Style" Value="{StaticResource ResourceKey=ListBoxItemBorder}"/>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=CurrentStatus}" Value="200">
            <Setter Property="Style" Value="{StaticResource ResourceKey=ListBoxItemBorderInactive}"/>
        </DataTrigger>
    </Border.Triggers>
</Border>
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

Failed object initialization (ISupportInitialize.EndInit). 
Triggers collection members must be of type EventTrigger.  
Error at object '4_T' in markup file
Run Code Online (Sandbox Code Playgroud)

我做错了什么错误的帮助.

wpf datatrigger

15
推荐指数
2
解决办法
4万
查看次数

c#WPF无法获取父窗口

我在窗口中托管了一个wpf页面.但是当我试图使用它时,我得到Null异常.它工作,然后我在另一种方法中使用此代码,但不是在alla方法中为什么会这样?请指教.

 NewPage page = new NewPage ();
 Window w = Window.GetWindow(this.Parent);
 w.Content = page;
Run Code Online (Sandbox Code Playgroud)

编辑:

继承人完整的代码:

    public HandOverListPage() {
        InitializeComponent();

        _settings = new Settings();
    }


    public void ShowCurrentInUseAssignment() {

        _currentDoc = (App.Current as App).SelectedHandOverDoc;

        var r = from item in (App.Current as App).SelectedHandOverDoc.Items
                where item.Status != 20
                select item;

        if(r.Count() == 0) {
            //Report assignment to QP with status finished
            ReportAssignment();

            HandOverPage page = new HandOverPage();

            Window w = Window.GetWindow(this.Parent);
            w.Content = page;

            return;
        } else {
            ICollectionView view = …
Run Code Online (Sandbox Code Playgroud)

c# wpf

9
推荐指数
2
解决办法
2万
查看次数

INotifyCollectionChanged:添加项目不会出现在给定索引'0'

我正在制作一个可观察的课程.Add方法工作正常.但后来我试图调用Remove()方法我得到这个错误:

"添加的项目不会出现在给定的索引'0'"

但是我将NotifyCollectionChangedAction枚举设置为Remove,如下面的代码所示.

    public class ObservableOrderResponseQueue : INotifyCollectionChanged, IEnumerable<OrderResponse>
{
    public event NotifyCollectionChangedEventHandler CollectionChanged;
    private List<OrderResponse> _list = new List<OrderResponse>();


    public void Add(OrderResponse orderResponse)
    {
        this._list.Add(orderResponse);
        if (CollectionChanged != null)
        {
            CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, orderResponse, 0));
        }
    }

    public void RemoveAt(int index)
    {
        OrderResponse order = this._list[index];
        this._list.RemoveAt(index);
        if (CollectionChanged != null)
        {
            CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, order, index));
        }
    }

    public void Remove(OrderResponse orderResponse)
    {
        var item = _list.Where(o => o.OrderDetail.TrayCode == orderResponse.OrderDetail.TrayCode).FirstOrDefault();
        int index = _list.IndexOf(item);

        this._list.RemoveAt(index);
        if (CollectionChanged …
Run Code Online (Sandbox Code Playgroud)

c# wpf

7
推荐指数
1
解决办法
6368
查看次数

C#BeginInvoke问题

为什么我有这个错误以及如何解决它.感谢帮助

错误4无法将lambda表达式转换为类型'System.Delegate',因为它不是委托类型

    void provider_GetAssignmentsComplete(object sender, QP_Truck_Model.Providers.GetAssignmentsEventArgs e) {
        lvMyAssignments.Dispatcher.BeginInvoke(() =>
        {
            lvMyAssignments.ItemsSource = e.HandOverDocs;
        });
    }
Run Code Online (Sandbox Code Playgroud)

c# wpf

6
推荐指数
1
解决办法
799
查看次数

SQL事件探查器无法捕获死锁图事件

我正在尝试解决死锁问题.当同时有超过10个用户时,我的应用程序会一直出现死锁.我尝试过使用SQL分析器,但无法弄明白.

问题是,在SQL Profiler中,我已经检查过使用死锁图事件.但是当我运行跟踪时,事件从未被记录.我可以看到有很多死锁和死锁链,但没有死锁图.请指教.感谢帮助

sql-server

5
推荐指数
1
解决办法
2604
查看次数

将现有服务设置为"自动(延迟启动)"

我正在尝试将已安装的 Windows服务设置为C#中的自动延迟启动.如何设置Windows服务

Automatic (Delayed Start) 
Run Code Online (Sandbox Code Playgroud)

无法在ServiceStartMode枚举中找到该值.

编辑:1

public class ServiceAutoStartInfo
{
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    private struct SERVICE_DELAYED_AUTO_START_INFO
    {

        public bool fDelayedAutostart;
    }

    [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    [return: MarshalAs(UnmanagedType.Bool)]
    private static extern bool ChangeServiceConfig2(IntPtr hService, int dwInfoLevel, IntPtr lpInfo);

    // Service configuration parameter 
    const int SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3;

    public bool ChangeDelayedAutoStart(IntPtr hService, bool delayed)
    {


        // Validate service handle
        if (hService != IntPtr.Zero)
        {


            // Create 
            SERVICE_DELAYED_AUTO_START_INFO info = new SERVICE_DELAYED_AUTO_START_INFO();

            // Set the DelayedAutostart property …
Run Code Online (Sandbox Code Playgroud)

c# service

5
推荐指数
1
解决办法
5110
查看次数

c#LINQ查看ISingleResult返回多少行帮助!

您正在使用ISingleResult与存储过程.如果Isingler是空的,我如何检查C#.因为有时候SP什么也不返回,有时则返回数据.

无论如何,ISingleResult包含多少行.感谢帮助.

c#

4
推荐指数
1
解决办法
4177
查看次数

在 WPF 中隐藏或删除部分边框

我想知道如何删除弹出窗口中的一小部分边框。我在图片中用红色箭头标记了要移除的部分。谢谢你的帮助。

这是 Xaml 代码

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
    <Grid SnapsToDevicePixels="true">
        <Rectangle x:Name="OuterBorder"/>
        <Rectangle x:Name="Bg" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}"/>
        <Rectangle x:Name="InnerBorder"/>
        <DockPanel>
            <ContentPresenter x:Name="Icon" ContentSource="Icon" Margin="4,0,6,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
            <Path x:Name="GlyphPanel" Data="{StaticResource Checkmark}" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="7,0,0,0" Visibility="Collapsed" VerticalAlignment="Center"/>
            <ContentPresenter ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        </DockPanel>
        <Popup x:Name="PART_Popup" AllowsTransparency="true" Focusable="false" HorizontalOffset="0" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom" VerticalOffset="-1">
            <Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
                <Border x:Name="SubMenuBorder" BorderBrush="{StaticResource ResourceKey=MenuBorderColorBrush}" BorderThickness="1" Background="{StaticResource MenuOpenBackgroundColorBrush}">
                    <ScrollViewer x:Name="SubMenuScrollViewer" Margin="1,0" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type …
Run Code Online (Sandbox Code Playgroud)

wpf

4
推荐指数
1
解决办法
2815
查看次数

Codeigniter Rest服务器摘要或基本身份验证登录

我正在使用Phil Sturgeon的REST服务器.我无法设置基本或摘要式身份验证.当调用方法时,我得到提示用户名和密码的对话框,即使我用正确的用户名和密码写它也不会接受它.我该如何解决这个问题?是我的网络主机不允许吗?

这就是我在rest.php中设置auth的方法:其余的是默认的.

$config['rest_auth']         = 'Basic';
$config['auth_source']       = '';
$config['rest_valid_logins'] = array('admin' => 'password');
Run Code Online (Sandbox Code Playgroud)

php rest codeigniter

4
推荐指数
2
解决办法
4489
查看次数

DDD 聚合根 使用静态方法创建对象是否正确

像这样的 Create 方法是否正确?或者我应该在服务内创建用户。这是否破坏了 DDD 概念?

对于这种情况,最佳做法是什么?

注意:我也使用 DI。

  public class User : HistoryBase, IAggregateRoot
    {
        private IEnumerable<Role> _roles = new List<Role>();
        public string Name { get; protected set; }
        public string Lastname { get; protected set; }
        public string Email { get; protected set; }
        public string Password { get; protected set; }
        public string EmployeeNumber { get; protected set; }
        public bool Active { get; protected set; }
        public int SiteID { get; protected set; }
        public IEnumerable<Role> Roles …
Run Code Online (Sandbox Code Playgroud)

c# domain-driven-design aggregateroot

4
推荐指数
1
解决办法
3874
查看次数