attachedbehaviors

Automatically calling OnDetaching() for Silverlight Behaviors

两盒软妹~` 提交于 2019-12-12 08:54:09
问题 I am using several Blend behaviors and triggers on a silverlight control. I am wondering if there is any mechanism for automatically detaching or ensuring that OnDetaching() is called for a behavior or trigger when the control is no longer being used (i.e. removed from the visual tree). My problem is that there is a managed memory leak with the control because of one of the behaviors. The behavior subscribes to an event on some long-lived object in the OnAttached() override and should be

TextBlock Inlines Attached Behavior Issue by LineBreak

大城市里の小女人 提交于 2019-12-12 03:44:35
问题 Hi is there a way to check if a Run is just a LineBreak ? Some explenation first suggesting you create some Text with some LineBreaks in a RichTextBox now let's further suggest after you want to save your text in a DataBase you will probably convert the FlowDocument as XML how i did now i want to show this "XML-string" in a TextBlock so i convert it back as FlowDocument write an GetAllLine extension and used a Attached Behavior to bind to TextBlock.Inlines end here my LineBreak Issue occurs

Generic DragDrop Behavior in WPF DataGrid

我怕爱的太早我们不能终老 提交于 2019-12-11 18:09:53
问题 I made a Behavior Drag Drop Beahvior which take a Collection (Implementing IList like ObservableCollection,LIst) And its working alrght... but if I Use CollectionViewSource.View (in the Xaml Binding), the behavior falis.... How could I make this behavior Generic (LIke independent of type of DataSource attached to DataGrid) Is it even possible as I am using methods for IList interface like Insert(object item) 回答1: This problem already has an open source solution, see Wpf Drag & Drop behaviour.

How to use the DragMoveBehaviorElement (drag) on a button in blend?

£可爱£侵袭症+ 提交于 2019-12-11 07:14:30
问题 i'm trying to make a draggable button in blend. using the dragmovebehaviorelement on a button does nothing, and i think this is because a button already uses the LeftMouseButon_down event. using this behavior on a shape (exp: ellipse) works fine. is there a way to make a draggable button? 回答1: It's not possible to use MouseDragElementBehavior with Button directly because the behavior will never receive the LeftButtonDown event. However, if you are will to change your UI a little, it can be

How can I attach two attached behaviors to one XAML element?

浪尽此生 提交于 2019-12-09 02:04:08
问题 I've implemented the attached command behavior pattern found here and it works well to allow e.g. a Border to have a left- or right-click event that fires in the ViewModel: XAML: <Border Background="Yellow" Width="350" Margin="0,0,10,0" Height="35" CornerRadius="2" c:CommandBehavior.Event="MouseLeftButtonDown" c:CommandBehavior.Command="{Binding PressedLeftButton}" c:CommandBehavior.CommandParameter="MainBorder123"> <TextBlock Text="this is the click area"/> </Border> Code Behind: public

Custom attached events in WPF

余生颓废 提交于 2019-12-07 17:32:23
问题 I might be getting the terminology wrong here, but I think I'm trying to create an attached event. In the Surface SDK, you can do things like: <Grid Background="{StaticResource WindowBackground}" x:Name="Foo" s:SurfaceFrameworkElement.ContactChanged="Foo_ContactChanged"/> I want to create a custom event for which a handler can be added in XAML in the same way, but I'm having trouble. I can create a custom routed event, but the XAML intellisense doesn't see it and the event handler isn't added

Custom attached events in WPF

依然范特西╮ 提交于 2019-12-06 03:32:18
I might be getting the terminology wrong here, but I think I'm trying to create an attached event. In the Surface SDK, you can do things like: <Grid Background="{StaticResource WindowBackground}" x:Name="Foo" s:SurfaceFrameworkElement.ContactChanged="Foo_ContactChanged"/> I want to create a custom event for which a handler can be added in XAML in the same way, but I'm having trouble. I can create a custom routed event, but the XAML intellisense doesn't see it and the event handler isn't added if I just type it in regularly. Here is my event definition: public static class TagRectEvents {

<i: Interaction.Behavior> option is not coming for applying beahviour

孤街浪徒 提交于 2019-12-06 01:33:53
问题 I have been trying to implement a behavior on a wpf window therefore I have added reference to System.Winodws.Interactivity in my current solution and then wrote the desired behavior. but in order to apply this behavior, I have to write something like this in Windows XAML. <Window x:Class="WpfApplication5.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:behav =

unit test an attached behavior wpf

送分小仙女□ 提交于 2019-12-05 23:09:01
问题 I am still grokking attached behaviors in general, and am at a loss to see how to write a unit test for one. I pasted some code below from Sacha Barber's Cinch framework that allows a window to be closed via attached behavior. Can somewone show me an example unit test for it? Thanks! Berryl #region Close /// <summary>Dependency property which holds the ICommand for the Close event</summary> public static readonly DependencyProperty CloseProperty = DependencyProperty.RegisterAttached("Close",

Automatically calling OnDetaching() for Silverlight Behaviors

倾然丶 夕夏残阳落幕 提交于 2019-12-04 08:07:56
I am using several Blend behaviors and triggers on a silverlight control. I am wondering if there is any mechanism for automatically detaching or ensuring that OnDetaching() is called for a behavior or trigger when the control is no longer being used (i.e. removed from the visual tree). My problem is that there is a managed memory leak with the control because of one of the behaviors. The behavior subscribes to an event on some long-lived object in the OnAttached() override and should be unsubscribing from that event in the OnDetaching() override so that it can become a candidate for garbage