首页 \ 问答 \ Wpf xaml继承(Wpf xaml inheritance)

Wpf xaml继承(Wpf xaml inheritance)

是否可以在两个不同的窗口中为ControlTemplate继承相同的样式? 我是wpf的新手,我不知道该怎么做,甚至不可能。 例如,如果我在Window1.xaml中:

<Window.Resources>
    <ControlTemplate x:Key="myStyle" TargetType="Button">
        ...
    </ControlTemplate>
</Window.Resources>

在Window2.xaml中,我想像这样使用它:

<Grid>
    <Grid.Resources>
        <Style TargetType="Button" BasedOn="{StaticResource myStyle}">
            ...
        </Style>
    </Grid.Resources>
<Grid>

如何从第一个窗口导入样式?


Is it possible to inherit same style for a ControlTemplate in two different windows? I'm new to wpf and I'm not sure how to do it or even if it's possible. For example if I have in Window1.xaml:

<Window.Resources>
    <ControlTemplate x:Key="myStyle" TargetType="Button">
        ...
    </ControlTemplate>
</Window.Resources>

And in Window2.xaml I want to use it like this:

<Grid>
    <Grid.Resources>
        <Style TargetType="Button" BasedOn="{StaticResource myStyle}">
            ...
        </Style>
    </Grid.Resources>
<Grid>

How do I import the style from the first window?


原文:https://stackoverflow.com/questions/5355924
更新时间:2023-10-20 21:10

最满意答案

“并且每次订阅者启动时他都会收到所有消息,如果我继续发送相同的消息,我的消费者将获得”

正如项目自述文件中所述

“最后一次价值交换就像直接交换”

所以这是预期的行为。

与直接交换的唯一区别在于,lvc交换机跟踪每个路由密钥的最后消息,因此当新队列与具有特定绑定密钥的交换机绑定时,最后一条消息以等于路由密钥的方式发布到交换机绑定密钥(存储在缓存中)被发送到新添加的队列。

要理解,您可以更改生产者代码,以便在第一个消费者与您的交易所绑定时只发送一条消息。 然后使用相同的绑定密钥将第二个使用者绑定到您的交换机,即使您的生产者不发送任何新消息,第二个使用者将获得与第一个使用者相同的消息,因为它已被lvc交换缓存。


"and everytime that the subscriber is up he receives all the messages, and if i keep sending the same message my consumer will get"

as stated in the readme of the project

"The last value exchange acts like a direct exchange"

so this is the expected behaviour.

The only difference with a direct exchange, is that the lvc exchange keeps track of last message for each routing key, so when a new queue is bond to the exchange with a specific binding key, last message published to the exchange with a routing key equal to the binding key (which was stored in cache) is sent to the newly added queue.

To understand, you could change your producer code to send only one message once a first consumer is bond to your exchange. Then bind a second consumer to your exchange, with same binding key, and even if your producer do not send any new message, the second consumer will get the same message than the first consumer, since it has been cached by the lvc exchange.

相关问答

更多
  • 那么,让我们仔细看看你上面描述的场景。 我认为在问题片段之前立即粘贴文档以提供上下文很重要: AMQP 0-9-1核心规范的第4.7节解释了保证排序的条件:在一个频道中发布的消息,通过一个交换机,一个队列和一个输出频道将按照它们发送的相同顺序接收。 自2.7.0版本以来,RabbitMQ提供了更强大的保证。 使用AMQP方法可以将消息返回到队列,这些方法具有一个requeue参数(basic.recover,basic.reject和basic.nack),或者由于在保存未确认消息时通道关闭。 任何这些情况 ...
  • 由于没有答复,我想我做得很好;) 无论如何,在与其他利益相关者讨论要求后,决定现在可以放弃LIFO要求。 当涉及到它时,我们可以担心。 我们可能最终采用的解决方案是让工作人员打开第二个队列,让主人可以使用该队列让工作人员知道要忽略哪些工作,并提供额外的控制/监视信息(无论如何我们都需要这些信息)。 实现AMQP 1.0规范的RabbitMQ也可能对此有所帮助。 所以我会把这个问题标记为现在的答案。 其他人仍然可以自由添加或改进。 Since there is no reply I guess I did m ...
  • “并且每次订阅者启动时他都会收到所有消息,如果我继续发送相同的消息,我的消费者将获得” 正如项目自述文件中所述 “最后一次价值交换就像直接交换” 所以这是预期的行为。 与直接交换的唯一区别在于,lvc交换机跟踪每个路由密钥的最后消息,因此当新队列与具有特定绑定密钥的交换机绑定时,最后一条消息以等于路由密钥的方式发布到交换机绑定密钥(存储在缓存中)被发送到新添加的队列。 要理解,您可以更改生产者代码,以便在第一个消费者与您的交易所绑定时只发送一条消息。 然后使用相同的绑定密钥将第二个使用者绑定到您的交换机,即 ...
  • 最终,我想到了什么是错的,但目前尚不清楚这是预期的行为,芹菜虫还是RabbitMQ bug。 发生的事情是,除了我们的应用程序任务之外,我还有一个自定义日志记录处理程序,用于使用RabbitMQ使用celery.send_task将日志发送到中心位置。 此日志记录处理程序使用诸如application.logger.info,application.logger.warning等路由键将消息发送到名为application.logger的交换,并具有绑定以将某些日志记录级别路由到特定队列。 此交换,绑定和队 ...
  • 从其他上下文中读取未确认的消息是不可能的,原始消息被消费并保持为未消息。 It's not possible to read unacknowledged messages from other context the original messages was consumed and held as un-aked.
  • 但是,我持续存在一些问题。 当我停止服务器时,等待一段时间并重新启动它,必须移动到WorkQueue的消息才会消失。 我做错了什么? 或者它是由设计? 您应该使用MessageProperties来实现消息持久性。 channel.basicPublish("", "task_queue", MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes()); 你当前的代码`channel.queueDeclare(“ ...
  • 消息确认就像SQL中的事务一样,提交时必须确认从RabbitMq收到的消息。 此功能有助于避免系统中的消息丢失。 导航到消息确认标题https://www.rabbitmq.com/tutorials/tutorial-two-python.html Message acknowledgement acts like transaction in SQL like commit you have to acknowledge the message received from RabbitMq. This ...
  • 或者使用作业调度程序将消息推送到消息队列更好,例如将rundeck与RabbitMQ结合使用? 是。 RabbitMQ不是为处理调度而设计的,并且尝试使用它只会是痛苦的(充其量)。 最好使用另一个调度系统,如cron jobs或rundeck或任何其他可用的调度工具。 通过该工具,您可以执行将在RabbitMQ中推送消息的代码,从而触发系统其他部分的工作。 Or is it better to use a job scheduler just to push messages to the message ...
  • 由于您已经有多个生成器系统创建日志,因此您已经拥有了分布式体系结构。 解决实用程序/交叉问题(如从每个系统进行日志记录)以及使用队列这样做有很多好处: 通过使用异步方法,您将能够在Rabbit中缓冲大量消息的峰值,而不会影响生产者系统的吞吐量。 此外,集中式日志写入系统可能能够批量日志插入 - 批量日志消息写入将需要更少的数据库连接,并且可以优化IO,超过每个直接写入少量日志的大量服务器所能实现的IO。 它集中了日志写作的关注。 这样,您不需要维护代码来在每个生产者上写日志,例如,如果日志格式或日志存储发生 ...
  • 未确认的消息将保持不确认状态,直到收到消息的消费者拒绝或拒绝该消息,或者连接/信道已关闭。 当连接/通道死亡时,Rabbitmq假定这些消息未被处理,因此它们可用于传递给另一个消费者。 为了防止将来发生这种情况,如果消费者不对它做任何事情和/或正确关闭与rabbitmq的连接/通道的逻辑,你应该在消费者中有一些拒绝/拒绝消息的逻辑。 The solution seems to be very simple. If you close the connection which has unacknowledg ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)