小编ie1*_*ie1的帖子

如何定义所有文本块元素相同的颜色

我们正在为大多数类型使用全局样式定义.我们在app.xaml文件中定义.使用TextBlock时,定义前景色是一个问题,因为它使用TextBlock(例如Button的内容颜色)更改所有控件.我们如何定义仅对特定TextBlock用法起作用的全局样式?

目前有问题的用法:

<Style TargetType={x:Type TextBlock}>
  <Setter Property="Foreground" Value="Red"/>
</Style>
Run Code Online (Sandbox Code Playgroud)

wpf styles

8
推荐指数
1
解决办法
236
查看次数

在另一个双精度资源中引用双精度资源

我想在另一个 Double 资源中引用 Double 资源,如下所示:

<sys:Double x:Key="width">100</sys:Double>

<sys:Double x:Key="height">{StaticResource width}</sys:Double>

我怎样才能做到这一点?

wpf resources xaml

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

更新组合框DisplayMemberPath中的显示字段(未显示)

我有一个wpf组合框。它的ItemsSource已绑定到ObservebaleCollection。显示的值(通过DisplayMemberPath)是Entity类的Name属性。问题是,当我更新当前选定的实体名称并触发NotifyPropertyChnage时,它不会在UI中更新(即使当我打开组合列表时,它也会在那里更新)。我想问题是实体哈希码仍然相同,并且组合看不到差异。我能做什么?

xaml:

<ComboBox     ItemsSource="{Binding Entities, Mode=OneWay}" 
          SelectedItem="{Binding CurrentEntity}"
          DisplayMemberPath="Name"/>
Run Code Online (Sandbox Code Playgroud)

码:

    public event PropertyChangedEventHandler PropertyChanged;

    ObservableCollection<Entity> m_entities = new ObservableCollection<Entity>();

    public ObservableCollection<Entity> Entities{get{return m_entities;}} 

    public Entity CurrentEntity{get;set}

    public void RenameEntity(string name)
    {
    m_currentEntity.Name = name;
    PropertyChanged(this, new PropertyChangedEventArgs("CurrentEntity"));
    PropertyChanged(this, new PropertyChangedEventArgs("Entities"));
    }
Run Code Online (Sandbox Code Playgroud)

.net wpf combobox

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

如何让IntPtr访问MemoryMappedFile的视图?

有没有办法直接获取IntPtrMemoryMappedFile中的数据?我有大数据块,频率变化很大,我不想复制它

c# memory-mapped-files intptr

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

ObserveOnDispatcher无法正常工作

我有2个线程,WPF + PIPE.我在管道rx事件上注册了WPF.当使用ObserveOnDispatcher()时,不会调用已注册的处理程序,当删除ObserveOnDispatcher()时,它会在管道线程上调用.有没有人有想法为什么在使用ObserveOnDispatcher()时根本没有调用它?

.net c# wpf system.reactive

3
推荐指数
1
解决办法
3733
查看次数

订阅作为最后一个方法提出

有没有办法订阅一个方法,虽然它会在引发onNext时被调用?

m_subject.Subscribe(() => Console.writeLine("firstSubscription");
m_subject.SubscribeLast(() => Console.writeLine("secondSubscription");
m_subject.Subscribe(() => Console.writeLine("thirdSubscription");

m_subject.OnNext();

// prints:
// firstSubscription
// thirdSubscription
// secondSubscription
Run Code Online (Sandbox Code Playgroud)

c# system.reactive

3
推荐指数
1
解决办法
84
查看次数

订购反应性扩展事件

我在多个线程中接收UDP上的消息.每次接待后我都会加注MessageReceived.OnNext(message).

因为我使用多个线程,所以无序引发的消息是一个问题.

如何通过消息计数器命令加注消息?(假设有一个message.counter属性)

必须记住一条消息可能会在通信中丢失(假设我们在X消息之后有一个计数器孔,那个洞没有填满我提出下一条消息)

必须尽快提出消息(如果收到下一个计数器)

udp reactive-programming system.reactive

3
推荐指数
1
解决办法
206
查看次数

如果中间有linq方法,则rx处理异常订阅

当我订阅有时抛出异常的方法时,我会得到2个不同的行为.如果我在中间连接LINQ方法,那么订阅就会被处理掉,另外一点也不是,为什么呢?

void main(){
  var numbersSubject=new Subject<int>();

  numbersSubject.subscribe(throwMethod);   // 1,2,3,4,6,7,8,9,10
  // numbersSubject.select(num=>num).subscribe(throwMethod);   // 1,2,3,4

  for(int i=0;i<10;i++)
  {
    try{
      numbersSubject.OnNext(i);
    }catch{}
  }
}

void throwMethod(int num)
{
   if(num==5)
       throw new Exception();
   Console.writeLine(i);
}
Run Code Online (Sandbox Code Playgroud)

c# reactive-programming system.reactive

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