Search Results

Search found 7209 results on 289 pages for 'wpf triggers'.

Page 16/289 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • WPF: Turning off animations, data binding temporarly for invisible objects?;)

    - by TomTom
    I have a window that contains a tab control - basically multiple sheets with visualizations on them. The visualtizations are: possible very resource intensive during rendering relying on constant data updates to update their underlying models Obviously only one sheet can be visible every time ;) Anyone knows of a good way to turn off all visualization, animations, data binding for a control / panel and it's contained controls? If I would find a way to do that, I could simply turn off all the invisible sheets and reactivate them as needed. The models must be kept running - some of the visual stuff is pretty complex and really relies on constant data updates, and recalculating it when someone switches tabs would be too hard.

    Read the article

  • How to track which character is deleted in TextBox in WPF?

    - by Ashish Ashu
    I want to track which character is deleted by the user through Delete or BackSpace Key. I am handling RichTextBox_ChangedEvent of textbox. Can I extract the deleted character from TextChangedEventArgs *e.Changes* and if yes How can I do that? I want to restrict user to from deleting any characters from the TextBox. I want user can delete only two characters ( let's say "(" or ")" ) Please suggest.

    Read the article

  • WPF - How to style the menu control to remove the left margin?

    - by BrianLy
    I have added a default menu control into my user control. It is being combined with some other controls as part of a custom Window chrome. I need to style the menu to make it appear simpler. The main thing I need to do is to remove the left margin containing the space for the icon or checkbox. How can I do this? XAML: <Menu> <MenuItem Header="MyMeny" FontSize="10"> <MenuItem Header="Options..." /> <MenuItem Header="About" /> </MenuItem> </Menu>

    Read the article

  • WPF - How do I use the UserControl with a dependency property and view model?

    - by user320849
    Hello, My goal is to have a user select a year and a month. Translate the selection into a date and have the user control send the date back to my view model. That part works for me....However, I cannot get the ViewModel's initial date to set those drop downs. public static readonly DependencyProperty Date = DependencyProperty.Register("ReturnDate", typeof(DateTime), typeof(DatePicker), new FrameworkPropertyMetadata{BindsTwoWayByDefault = true,}); public DateTime ReturnDate { get { return Convert.ToDateTime(GetValue(Date)); } set { SetDropDowns(value); SetValue(Date, value); } } The SetDropDowns(value) just sets the selected items on the combo boxes, however, the program never makes it to that method. On the view I am using: <cc1:DatePicker ReturnDate="{Binding Path=StartDate, Mode=TwoWay}" IsStart="True" /> If this has been answered, then my bad. I looked around and didn't see anything that worked for me. Thus, when the program loads how do I get the value from the view model to a method in order to set the combo boxes? Thanks, -Scott

    Read the article

  • WPF-Can a XAML object be a source as well as a target for bindings?

    - by iambic77
    I was wondering if it's possible to have a TextBlock as a target and a source? Basically I have a bunch of entities which have simple relationships to other entities (like Entity1 Knows Entity3, Entity3 WorksAt Entity2 etc.) I have a Link class that stores SourceEntity, Relationship and TargetEntity details. What I want to be able to do is to select an entity then display the relationships related to that entity, with the target entities of each relationship listed underneath the relationship names. When an entity is selected, an ObservableCollection is populated with the Links for that particular entity (SelectedEntityLinks<Link>). Because each entity could have the same relationship to more than one target entity (Entity1 could know both Entity3 and Entity4 for eg.), I've created a method GetThisRelationshipEntities() that takes a relationship name as a parameter, looks through SelectedEntityLinks for relationship names that match the parameter, and returns an ObservableCollection with the target entities of that relationship. Hope I'm making this clear. In my xaml I have a WrapPanel to display each relationship name in a TextBlock: <TextBlock x:Name="relationship" Text="{Binding Path=Relationship.Name}" /> Then underneath that another Textblock which should display the results of GetThisRelationshipEntities(String relationshipName). So I want the "relationship" TextBlock to both get its Text from the binding I've shown above, but also to provide its Text as a parameter to the GetThisRelationshipEntities() method which I've added to <UserControl.Resources> as an ObjectDataProvider. Sorry if this is a bit wordy but I hope it's clear. Any pointers/advice would be great. Many thanks.

    Read the article

  • Problem in DataBinding an Enum using dictionary approach to a combobox in WPF.

    - by Ashish Ashu
    I have a Dictionary which is binded to a combobox. I have used dictionary to provide spaces in enum. public enum Option {Enter_Value, Select_Value}; Dictionary<Option,string> Options; <ComboBox x:Name="optionComboBox" SelectionChanged="optionComboBox_SelectionChanged" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedItem="{Binding Path = SelectedOption}" ItemsSource="{Binding Path = Options}" /> This works fine. My queries: 1. I am not able to set the initial value to a combo box. In above XAML snippet the line SelectedItem="{Binding Path = SelectedOption}" is not working. I have declared SelectOption in my viewmodel. This is of type string and I have intialized this string value in my view model as below: SelectedOption = Options[Options.Enter_Value].ToString(); 2. The combobox is binded to datadictionary which have two options first is "Enter_value" and second is "Select_value" which is actually Option enum. Based on the Option enum value I want to perform different action. For example if option is equal to option.Enter_value then Combo box becomes editable and user can enter the numeric value in it. if option is equal to option.Select_value value then the value comes from the database and the combo box becomes read only and shows the fetched value from the database. Please Help!!

    Read the article

  • In WPF, how do I update the object that my custom property is bound to?

    - by Timothy Khouri
    I have a custom property that works perfectly, except when it's bound to an object. The reason is that once the following code is executed: base.SetValue(ValueProperty, value); ... then my control is no longer bound. I know this because calling: base.GetBindingExpression(ValueProperty); ... returns the binding object perfectly - UNTIL I call base.SetValue. So my question is, how do I pass the new "value" on to the object that I'm bound to?

    Read the article

  • Sharing a texture resource from DX11 to DX9 to WPF, need to wait for DeviceContext.Flush() to finish

    - by Rei Miyasaka
    I'm following these instructions on TheCodeProject for rendering from DirectX to WPF using D3DImage. The trouble is that now that I have no swap chain to call Present() on -- which according to the article shouldn't be a problem, but it definitely wasn't copying my back buffer. An additional step that I have to take before I can copy the texture to WPF is to share it with a second D3D9Ex device, since D3DImage only works with DX9 (which is understandable, as WPF is built on DX9). To that end, I've modified some SlimDX code to work with DirectX 11. I tried calling DeviceContext.Flush() (the Immediate one) at the end of each render cycle, which kind of works -- most of the time it'll show my renderings, but maybe for maybe 3 or 4 out of 60 frames each second, it'll draw my clear color instead. This makes sense -- Flush() is non-blocking; it doesn't wait for the GPU to do its thing the way SwapChain.Present does. Any idea what the proper solution is? I have a feeling it has something to do with my texture parameters for the back buffer, but I don't know.

    Read the article

  • Why, in WPF, do we set an object to Stretch via its Alignment properties instead of Width/Height?

    - by Jonathan Hobbs
    In WPF's XAML, we can tell an element to fill its container like this: <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> Why is it that when we set an element to Stretch, we do it via the HorizontalAlignment and VerticalAlignment properties? Why did the WPF design team decide to take this approach over having Width="Stretch" and Height="Stretch"? I presume it was a calculated decision, and I'm curious about the reasoning. CSS, among other technologies, follows the convention that stretching is done via the width and height properties, and that alignment affects positioning exclusively. This seems intuitive enough: stretching the element is manipulating its width and height, after all! Using the corresponding alignment property to stretch an element seems counter-intuitive and unusual in comparison. This makes me think they didn't just pick this option for no reason: they made a calculated decision and had reasons behind it. Width and Height use the double data type, which would ordinarily mean assigning it a string would be silly. However, WPF's Window objects can take Width="Auto", which gets treated as double.NaN. Couldn't Width="Stretch" be stored as double.PositiveInfinity or some other value?

    Read the article

  • How to know if a graphics card provides hardware rendering for wpf

    - by happyclicker
    I have to run a wpf-app in an environment that has all the same dell-pc's with an intel gma 3000 graphics chip (onbard, Q963/Q965). The app renders only with software rendering (Stated so by the RenderCapability.Tier-property (it says the rendering tier is 0!) and I also see this with Perforator). On all of this machines, DirectX 9c is installed and DXDiag states on many but not on all of this machines, that Direct-3d and Direct-Draw-acceleration is activated. I checked also the registry if the setup of these machines disabled wpf-hw rendering but that's also not the case. On one machine I also updated the video-driver and dx with no success. I found a lot of ressources that say, that directX must be installed and active, so that wpf does not use its own software renderer but uses the DirectX HW-Rendering. But on the above machines, DX9c is installed but there is no hw rendering. May it be that wpf uses dx-graphicscards but does the communication with the graphics card direct and not over dx? How can I find out if a specific graphics-chip has to support hardware rendering for wpf or not. The statement that the graphics card must support dx 9c seems not to be the only condition. The second question is, if wpf renders through dx, is this done through direct-3d or is direct-draw used. Is there any good documentation on this topic?

    Read the article

  • WPF issue: Showing HTML <DIV> on top of WPF app

    - by Kangkan
    Hi, I am new to WPF. We are facing one issue. We are showing/launching a WPF browser application from an web (ASPX) application. The web application has a navigator menu with drop-downs (on hover). It works fine till the user is using the web application (aspx pages). But once the WPF application is launched (and is in the foreground on the aspx page) the dropdown menus that are on top of the WPF app is shown below the WPF application. The drop downs are in a <div> and we tried to put the ZINDEX value. But could not get any positive reply. Can somebody help?

    Read the article

  • [WPF] ComboBox Style problems with DisplayMemberPath

    - by kornelijepetak
    I have a ComboBox and I have set the combo.ItemsSource property to a List object. The Book class contains two properties: "Abbreviation" and "Name". I have set the ComboBox's DisplayMemberPath to "Abbreviation" but the following style that is set on the ComboBox does not display the Abbreviation property, but instead shows "Words.Book" which is the name of the class. The ComboBox drop-down displays a list correctly (Using the specified Abbreviation property). The problem is in the selected ComboBox item, the one displayed when the ComboBox' drop-down is closed. I guess the problem is in ContentPresenter in DataTemplate but I was unable to find a successful solution. Currently the ContentPresenter's Content property is set to Content="{TemplateBinding Content} but I don't know if that's how it should be. Any ideas how to show the property specified in DisplayMemberPath on the selected item? Thank you the code: <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition Width="20" /> </Grid.ColumnDefinitions> <Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="2" BorderThickness="1" Background="{DynamicResource ribbonTitleFade}" /> <Border Grid.Column="0" CornerRadius="2,0,0,2" Margin="1,6,1,6" BorderBrush="{DynamicResource boSecE}" BorderThickness="0,0,1,0" /> <Path x:Name="Arrow" Grid.Column="1" Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 4 4 L 8 0 Z" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="ToggleButton.IsMouseOver" Value="true"> <Setter TargetName="Border" Property="Background" Value="{DynamicResource ribbonTitleFade}" /> </Trigger> <Trigger Property="ToggleButton.IsChecked" Value="true"> <Setter TargetName="Border" Property="Background" Value="{DynamicResource ribbonTitleFade}" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="Border" Property="Background" Value="Black" /> <Setter TargetName="Border" Property="BorderBrush" Value="Black" /> <Setter Property="Foreground" Value="Gray"/> <Setter TargetName="Arrow" Property="Fill" Value="Gray" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> <Style x:Key="comboBoxBorderTransparent" TargetType="Control"> <Setter Property="BorderBrush" Value="{DynamicResource boPrimC}" /> </Style> <Style x:Key="comboItemStyle" TargetType="ComboBoxItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ComboBoxItem}"> <Border x:Name="backBorder" > <StackPanel Orientation="Horizontal"> <Rectangle x:Name="rectA" Stroke="White" Width="4" Height="4" Fill="#80FFFFFF" Margin="5,0,0,0" HorizontalAlignment="Left" /> <TextBlock x:Name="text" Foreground="White" FontSize="10px"> <ContentPresenter Margin="8,1,0,1" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> </TextBlock> </StackPanel> </Border> <ControlTemplate.Triggers> <Trigger Property="ComboBoxItem.IsMouseOver" Value="true"> <Setter TargetName="rectA" Property="Stroke" Value="Black" /> <Setter TargetName="rectA" Property="Fill" Value="#80000000" /> <Setter TargetName="backBorder" Property="Background" Value="White"/> <Setter TargetName="text" Property="Foreground" Value="{DynamicResource boPrimC}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <DataTemplate x:Key="comboSelectedItemTemplate"> <TextBlock Foreground="White" FontSize="10px"> <ContentPresenter Content="{TemplateBinding Content}" /> </TextBlock> </DataTemplate> <Style TargetType="ComboBox"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.CanContentScroll" Value="true"/> <Setter Property="MinWidth" Value="60"/> <Setter Property="MinHeight" Value="20"/> <Setter Property="ItemContainerStyle" Value="{DynamicResource comboItemStyle}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ComboBox"> <Grid> <ToggleButton Name="ToggleButton" Grid.Column="2" Template="{StaticResource ComboBoxToggleButton}" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"> </ToggleButton> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Name="ContentSite" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{DynamicResource comboSelectedItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Margin="3,3,23,3" /> <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="False" Focusable="False" PopupAnimation="Slide"> <Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}"> <Border x:Name="DropDownBorder" Background="{DynamicResource ribbonTitleFade}" BorderThickness="1" BorderBrush="{DynamicResource boPrimC}" /> <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True"> <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" /> </ScrollViewer> </Grid> </Popup> </Grid> <ControlTemplate.Triggers> <Trigger Property="HasItems" Value="false"> <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="Black"/> </Trigger> <Trigger Property="IsGrouping" Value="true"> <Setter Property="ScrollViewer.CanContentScroll" Value="false"/> </Trigger> <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true"> <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="2"/> <Setter TargetName="DropDownBorder" Property="Margin" Value="0"/> </Trigger> <Trigger Property="IsEditable" Value="true"> <Setter Property="IsTabStop" Value="false"/> <!--<Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>--> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> </Style.Triggers> </Style>

    Read the article

  • WPF Alphabet (Available for download)

    - by mbcrump
    WPF Alphabet is a application that I created to help my child learn the alphabet. It displays each letter and pronounces it using speech synthesis. It was developed using WPF and c# in about 3 hours (so its kinda rough). I went ahead and uploaded it to codeplex for those in similar situation or just wanting to see a particular WPF feature. I would also recommend Scott Hanselman’s BabySmash!. Specific WPF Features: DispatcherTimer (WPF) SpeechSynthesizer (WPF) URL Navigate (WPF) not PAGE XAML Examples: DockPanel Border TextBlock HyperLink Button's and Events Download full source and binaries here.

    Read the article

  • How to define a default tooltip style for all Controls

    - by skjagini
    I would like to define a style with a template when there are validation errors and would display the first error message as a tooltip. It works fine when targeting specific control like DatePicker in the following xaml. <Style TargetType="{x:Type ToolKit:DatePicker}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> </Style> I cannot get it to work for Control though, i.e. the following doesn't give any tooltip <Style TargetType="{x:Type ToolKit:Control}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> </Style> Any idea?

    Read the article

  • Databinding between 2 Dependency Properties

    - by stefan.at.wpf
    Hello, I'm trying to do databinding between 2 Dependency Properties. I guess this should be quite easy, anyways I just don't get it. I already googled but I couldn't really find out what I'm doing wrong. I'm trying to bind the ControlPointProperty to the QuadraticBezierSegment.Point1Property, however it doesn't work. Thanks for any hint! class DataBindingTest : DependencyObject { // Dependency Property public static readonly DependencyProperty ControlPointProperty; // .NET wrapper public Point ControlPoint { get { return (Point)GetValue(DataBindingTest.ControlPointProperty); } set { SetValue(DataBindingTest.ControlPointProperty, value); } } // Register Dependency Property static DataBindingTest() { DataBindingTest.ControlPointProperty = DependencyProperty.Register("ControlPoint", typeof(Point), typeof(DataBindingTest)); } public DataBindingTest() { QuadraticBezierSegment bezier = new QuadraticBezierSegment(); // Binding Binding myBinding = new Binding(); myBinding.Source = ControlPointProperty; BindingOperations.SetBinding(bezier, QuadraticBezierSegment.Point1Property, myBinding); // Test Binding: Change the binding source ControlPoint = new Point(1, 1); MessageBox.Show(bezier.Point1.ToString()); // gives (0,0), should be (1,1) } }

    Read the article

  • WPF: Reloading app parts to handle persistence as well as memory management.

    - by Ingó Vals
    I created a app using Microsoft's WPF. It mostly handles data reading and input as well as associating relations between data within specific parameters. As a total beginner I made some bad design decision ( not so much decisions as using the first thing I got to work ) but now understanding WPF better I'm getting the urge to refactor my code with better design principles. I had several problems but I guess each deserves it's own question for clarity. Here I'm asking for proper ways to handle the data itself. In the original I wrapped each row in a object when fetched from database ( using LINQ to SQL ) somewhat like Active Record just not active or persistence (each app instance had it's own data handling part). The app has subunits handling different aspects. However as it was setup it loaded everything when started. This creates several problems, for example often it wouldn't be neccesary to load a part unless we were specifically going to work with that part so I wan't some form of lazy loading. Also there was problem with inner persistance because you might create a new object/row in one aspect and perhaps set relation between it and different object but the new object wouldn't appear until the program was restarted. Persistance between instances of the app won't be huge problem because of the small amount of people using the program. While I could solve this now using dirty tricks I would rather refactor the program and do it elegantly, Now the question is how. I know there are several ways and a few come to mind: 1) Each aspect of the program is it's own UserControl that get's reloaded/instanced everytime you navigate to it. This ensures you only load up the data you need and you get some persistancy. DB server located on same LAN and tables are small so that shouldn't be a big problem. Minor drawback is that you would have to remember the state of each aspect so you wouldn't always start at beginners square. 2) Having a ViewModel type object at the base level of the app with lazy loading and some kind of timeout. I would then propegate this object down the visual tree to ensure every aspect is getting it's data from the same instance 3) Semi active record data layer with static load methods. 4) Some other idea What in your opinion is the most practical way in WPF, what does MVVM assume?

    Read the article

  • Should I learn WPF? Is it a good time investment? [closed]

    - by Arash
    First I should say this is a copy of this question. I am a C# developer, not an expert, but still learning and growing. I want to learn WPF so I can creat application with nice UI. However I am afraid that, after I spend my time learning it, it is gonna be obselete, you know with windows 8 and metro application and stuff, so my question is: At this pint of time, would it be a good time investment to learn WPF? or will I be better off learning Metro? Thanks.

    Read the article

  • Trouble applying a simple template

    - by Adam S
    I'm having trouble applying a template to my checkboxes. I have the following template: <ControlTemplate x:Key="TriStateRed" TargetType="{x:Type CheckBox}"> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="{x:Null}" > <Setter TargetName="path" Property="Data" Value="M 0 2.5 A 5 2.5 0 1 1 5 5 L 5 8 M 5 10 L 5 10" /> <Setter TargetName="path" Property="Stroke" Value="Red" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> However, visual studio gives me the following error: Cannot find the Trigger target 'path'. (The target must appear before any Setters, Triggers, or Conditions that use it.) Can anyone make sense of this?

    Read the article

  • WPF TreeViewItem + Change the Highlight Color

    - by flurreh
    Hello, I have got a TreeView with a HierarchicalDataTemplate. <HierarchicalDataTemplate x:Key="treeViewItemTemplate" ItemsSource="{Binding GetChildren}"> <DockPanel Margin="0,8,8,0"> <Image Source="{Binding GetImage}" Width="16" Height="16" /> <local:MonitorTriStateCheckBox Margin="4,0,0,0" IsChecked="{Binding IsChecked}" Click="CheckBox_Clicked" Tag="{Binding UniqueKey}" Style="{DynamicResource CheckBox}"></local:MonitorTriStateCheckBox> <TextBlock Margin="4,0,0,0" Text="{Binding Name}" Style="{DynamicResource TextBlock}"> </TextBlock> </DockPanel> <HierarchicalDataTemplate.Triggers> <Trigger Property="TreeViewItem.IsSelected" Value="True"> <Setter Property="TreeViewItem.Background" Value="Orange" /> </Trigger> </HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate> As you can see in the code, i set the is selected Trigger of the TreeViewItem, but this has no effect. I alos tried this: <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> <Setter Property="Visibility" Value="{Binding IsVisible, Mode=TwoWay}" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="Orange" /> </Trigger> </Style.Triggers> </Style> </TreeView.ItemContainerStyle> But that had no effect either. Has anyone got an idea what to do, to change the hightlight color of a TreeViewItem?

    Read the article

  • WPF Image change source when button is disabled

    - by Taylor
    Hi, I'm trying to show a different image when the button is disabled. Should be easy with triggers, right?! For some reason, I have not been able to get the images to switch. I've tried setting triggers on both the image and button. What is wrong with what I have below? How can I change the image source when the button is enabled/disabled? Thanks! <Button x:Name="rleft" Command="{Binding Path=Operation}" CommandParameter="{x:Static vm:Ops.OpA}"> <Button.Content> <StackPanel> <Image Width="24" Height="24" RenderOptions.BitmapScalingMode="NearestNeighbor" SnapsToDevicePixels="True" Source="/MyAssembly;component/images/enabled.png"> <Image.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=rleft, Path=Button.IsEnabled}" Value="False"> <Setter Property="Image.Source" Value="/MyAssembly;component/images/disabled.png" /> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> </StackPanel> </Button.Content> </Button>

    Read the article

  • WPF - binding ElementName problem...

    - by zvi
    Hello First Sorry for my English. I wanted to ask why ElementName does not work the first case, and work in the second. I give the two sections of code . the firts not work <Button Name="button1" Width="100" > <Button.LayoutTransform> <ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/> </Button.LayoutTransform> <Button.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation Storyboard.Target="{Binding ElementName=ttt}" Storyboard.TargetProperty="ScaleX" From="10" To="5" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Button.Triggers> Button </Button> But it does work <Button Name="button1" Width="100" > <Button.LayoutTransform> <ScaleTransform x:Name="ttt" ScaleX="3" ScaleY="6"/> </Button.LayoutTransform> <Button.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard RepeatBehavior="Forever"> <DoubleAnimation Storyboard.Target="{Binding ElementName=button1}" Storyboard.TargetProperty="Width" From="100" To="50" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Button.Triggers> Button </Button> I know I can use Storyboard.TargetName .

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >