Search Results

Search found 5961 results on 239 pages for 'wpf 4 5'.

Page 60/239 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • Smooth text animation (Marquee) using WPF

    - by Goran
    Trying to build a marquee control with smooth text animation. Current efforts include: Using translate transform Using animation on Canvas dependency properties (Left, Right) Using animation on custom dependency property (Point) and using drawing visuals (formattedtext) Using CompositionTarget.Rendering But the animation is still choppy and resource intensive. Checklist: Confirmed no software rendering is taking place (ms performance tool and checking RenderCapability.Tier) Calling freeze on any imaginable object Running app on dual core machine with decent graphic card (NVidia 9600) Disabled any bitmap effect and transparency Checked all marquee controls out there (same issues) Any ideas (or better yet code example)?

    Read the article

  • WPF: Master - detail view with two datagrids and in MVVM

    - by EV
    Hi, I'm trying to write a master - detail control that consists of a master datagrid and the detail datagrid. My scenario was following - I used the SelectedItem and bound it to a property in ModelView. The problem is - the SelectedItem in ViewModel is never used, so I can't get the information which item is selected in a master datagrid and cannot fetch the data for thos selection. The code is below: <toolkit:DataGrid ItemsSource="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected" SelectedItem="{Binding SelectedItemHandler, Mode=TwoWay}"></toolkit:DataGrid> And in ViewModel private CustomerObjects _selectedItem; public CustomerObjects SelectedItemHandler { get { return _selectedItem; } set { OnPropertyChanged("SelectedItem"); } } The code in SelectedItemHandler is never used. What could be the problem? Should I use another approach to create master - detail in MVVM?

    Read the article

  • WPF: Asynchronous progress bar

    - by SumGuy
    I'm trying to create a progress bar that will work asynchronously to the main process. I'm created a new event and invoked it however everytime I then try to perform operations on the progress bar I recieve the following error: "The calling thread cannot access this object because a different thread owns it" The following code is an attempt to send an instance of the progress bar to the event as an object, it obviously failed but it gives you an idea of what the code looks like. private event EventHandler importing; void MdbDataImport_importing(object sender, EventArgs e) { ProgressBar pb = (ProgressBar)sender; while (true) { if (pb.Value >= 200) pb.Value = 0; pb.Value += 10; } } private void btnImport_Click(object sender, RoutedEventArgs e) { importing += new EventHandler(MdbDataImport_importing); IAsyncResult aResult = null; aResult = importing.BeginInvoke(pbDataImport, null, null, null); importing.EndInvoke(aResult); } Does anyone have ideas of how to do this. Thanks in advance SumGuy.

    Read the article

  • WPF: Filter TreeView without collapsing it's nodes

    - by Julian Lettner
    This one is a follow-up question. I filter the top level nodes of a TreeView control like shown below. private void ApplyFilterHandler(object sender, RoutedEventArgs e) { if (_filterCheckBox.IsChecked.Value) CollectionViewSource.GetDefaultView(TopLevelNodes).Filter += MyFilter; else CollectionViewSource.GetDefaultView(TopLevelNodes).Filter -= MyFilter; } . <TreeView ItemsSource="{Binding TopLevelNodes}"> ... </TreeView> When the user applies the filter all nodes get collapsed. Question How can I hide certain nodes in a tree while retaining the expand state of the other nodes? Can someone explain, what happens internally on ICollectionView.Filter += MyFilter. Thanks for your time.

    Read the article

  • Add collection or array to wpf resource dictionary

    - by Chris Cap
    I've search high and low and can't find an answer to this. I have two questions How do you create an array or collection in XAML. I've got an array I want to stick in there and bind to a combo box. My first idea was to put an ItemsControl in a resource dictionary, but the ItemsSource of a combo box expects IEnumerable so that didn't work. Here's what I've tried in my resource dictionary and neither works <ItemsControl x:Key="stateList"> <sys:String>AL</sys:String> <sys:String>CA</sys:String> <sys:String>CN</sys:String> </ItemsControl> <ItemsControl x:Key="stateList2"> <ComboBoxItem>AL</ComboBoxItem> <ComboBoxItem>CA</ComboBoxItem> <ComboBoxItem>CN</ComboBoxItem> </ItemsControl> and here's how I bind to it <ComboBox SelectedValue="{Binding Path=State}" ItemsSource="{Binding Source={StaticResource stateList2}}" > </ComboBox> EDIT: UPDATED I got this first part to work this way <col:ArrayList x:Key="stateList3"> <sys:String>AL</sys:String> <sys:String>CA</sys:String> <sys:String>CN</sys:String> </col:ArrayList> However, I'd rather not use an array list, I'd like to use a generic list so if anyone knows how please let me know. EDIT UPDATE: I guess XAML has very limited support for generics so maybe an array list is the best I can do for now, but I would still like help on the second question if anyone has an anser 2nd. I've tried referencing a merged resource dictionary in my XAML and had problems because under Window.resources I had more than just the dictionary so it required me to add x:Key. Once I add the key, the system can no longer find the items in my resource dictionary. I had to move the merged dictionary to Grid.Resources instead. Ideally I'd like to reference the merged dictionary in the app.xaml but I have the same problem Here's some sample code. This first part required an x:key to compile because I have converter and it complained that every item must have a key if there is more than one <UserControl.Resources> <win:BooleanToVisibilityConverter x:Key="VisibilityConverter" /> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/ResourcesD.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> I had to change it to this <UI:BaseStep.Resources> <win:BooleanToVisibilityConverter x:Key="VisibilityConverter" /> </UI:BaseStep.Resources> <Grid> <Grid.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/ResourcesD.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Grid.Resources> </Grid> Thank you

    Read the article

  • Access to bound data in IMultiValueConverter.ConvertBack() in C#/WPF

    - by absence
    I have a problem with a multibinding: <Canvas> <local:SPoint x:Name="sp" Width="10" Height="10"> <Canvas.Left><!-- irrelevant binding here --></Canvas.Left> <Canvas.Top> <MultiBinding Converter="{StaticResource myConverter}" Mode="TwoWay"> <Binding ElementName="cp1" Path="(Canvas.Top)"/> <Binding ElementName="cp1" Path="Height"/> <Binding ElementName="cp2" Path="(Canvas.Top)"/> <Binding ElementName="cp2" Path="Height"/> <Binding ElementName="sp" Path="Height"/> <Binding ElementName="sp" Path="Slope" Mode="TwoWay"/> </MultiBinding> </Canvas.Top> </local:SPoint> <local:CPoint x:Name="cp1" Width="10" Height="10" Canvas.Left="20" Canvas.Top="150"/> <local:CPoint x:Name="cp2" Width="10" Height="10" Canvas.Left="100" Canvas.Top="20"/> </Canvas> In order to calculate the Canvas.Top value, myConverter needs all the bound values. This works great in Convert(). Going the other way, myConverter should ideally calculate the Slope value (Binding.DoNothing for the rest), but it needs the other values in addition to the Canvas.Top one passed to ConvertBack(). What is the right way to solve this? I have tried making the binding OneWay and create an additional multibinding for local:SPoint.Slope, but that causes infinite recursion and stack overflow. I was thinking the ConverterParameter could be used, but it seems like it's not possible to bind to it.

    Read the article

  • WPF MenuItem IsChecked Binding not working

    - by Kaya
    Anyone know why the menu item binding does not work ? <ToggleButton Name="toggleButton" Checked="checkBoxPublish_Checked" > <ToggleButton.Resources> <converters:BooleanToHiddenVisibility x:Key="boolToVis"/> </ToggleButton.Resources> <Grid> <Image Height="auto" HorizontalAlignment="Left" Margin="5" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="auto" /> <Viewbox > <TextBlock Text="Blocked" Opacity="0.7" Foreground="Red" Visibility="{Binding Path=IsChecked, ElementName=toggleButton, Converter={StaticResource boolToVis}}"/> </Viewbox> </Grid> <ToggleButton.ContextMenu> <ContextMenu StaysOpen="True" > <MenuItem x:Name="menuItemBlock" Header="Block" Click="menuItemClick" IsCheckable="True" IsChecked="{Binding ElementName=toggleButton, Path=IsChecked}"/> <MenuItem x:Name="menuItemIgnorePtz" Header="Ignore Ptz" Click="menuItemClick" IsCheckable="True" /> </ContextMenu> </ToggleButton.ContextMenu> </ToggleButton>

    Read the article

  • Paragraph formatting in a WPF RichTextBox?

    - by David Veeneman
    I need to apply paragraph formatting to a selection in a rich text box. My RTB will behave the same way as the rich text boxes on StackOverflow--the user can type text into the RTB, but they can also enter code blocks. The RTB will apply very simple formatting to the code block--it will change the font and apply a background color to the entire block, similar to what you see in the code block below. Changing the font is pretty straightforward: var textRange = new TextRange(rtb.Selection.Start, rtb.Selection.End); textRange.ApplyPropertyValue(TextElement.FontFamilyProperty, "Consolas"); textRange.ApplyPropertyValue(TextElement.FontSizeProperty, 10D ); Now I need to apply some paragraph-level formatting. I need to set the paragraph margin to 0, so I don't get a blank line between code lines, and I need to set the paragraph background color. Here's my problem: I can't figure out how to get the paragraph elements from the selection, so that I can apply formatting. Any suggestions? An example of how to apply the Margin and Background properties would be incredibly helpful. Thanks!

    Read the article

  • WPF: DataGrid Cell Double-click

    - by Jonathan Allen
    Is there a better way than this to determine the row a user double-clicked on in a data-grid? Private Sub ResultsGrid_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Dim node As DependencyObject = CType(e.OriginalSource, DependencyObject) Do Until TypeOf node Is Microsoft.Windows.Controls.DataGridRow OrElse node Is Nothing node = VisualTreeHelper.GetParent(node) Loop If node IsNot Nothing Then Dim data = CType((CType(node, Microsoft.Windows.Controls.DataGridRow)).DataContext, Customer) 'do something End If End Sub

    Read the article

  • Create ControlTemplate programmatically in wpf

    - by Thomas Stock
    Hi, How can I programmatically set a button's template? Polygon buttonPolygon = new Polygon(); buttonPolygon.Points = buttonPointCollection; buttonPolygon.Stroke = Brushes.Yellow; buttonPolygon.StrokeThickness = 2; // create ControlTemplate based on polygon ControlTemplate template = new ControlTemplate(); template.Childeren.Add(buttonPolygon); // This does not work! What's the right way? //create button based on controltemplate Button button = new Button(); button.Template = template; So I need a way to set my Polygon as the button's template.. Suggestions? Thanks.

    Read the article

  • WPF Delay Refresh of UI Elements in ItemsControl

    - by Wonko the Sane
    Hello All, The short question is - how can I prevent (delay) a bound UI element from refreshing until I want it to? The longer explanation: I have a process that adds a number of items to an ItemsControl, and then performs some additional calculations on those items using a background thread. This (correctly) updates the items as it goes along. However, I would like to prevent the ItemsControl from updating during a particular calculation, as it performs some reordering of the items before it does additional calculations based on that order, and then returns the items to their original order. I do show a "Please Wait" animation on top of the ItemsControl, with the ItemsControl dimmed down as it is working, but I'd rather not hide the ItemsControl entirely because it gives the user an indication that progress is being made. Thanks, wTs

    Read the article

  • wpf DataGrid.datagridtemplatecolumn combobox does not update itemssource

    - by David
    <Grid Loaded="Grid_Loaded"> <DataGrid Margin="10,10,10,162" x:Name="dataGrid1" ItemsSource="{Binding myItemsSource}"/> <DataGrid Margin="10,164,10,10" x:Name="dataGrid2" ItemsSource="{Binding myItemsSource}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="A" Binding="{Binding A}"></DataGridTextColumn> <DataGridComboBoxColumn Header="B" TextBinding="{Binding B}" x:Name="columnB"></DataGridComboBoxColumn> <DataGridTemplateColumn Header="C" x:Name="columnC"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox Text="{Binding C, Mode=TwoWay}" SelectedItem="{Binding C, Mode=TwoWay}"> <ComboBoxItem Content="AAA"/> <ComboBoxItem Content="BBB"/> <ComboBoxItem Content="CCC"/> <ComboBoxItem Content="XXX"/> <ComboBoxItem Content="YYY"/> <ComboBoxItem Content="ZZZ"/> </ComboBox> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid> columnB (buidin DataGridComboBoxColumn) is working. columnB.ItemsSource = LstForCbx; public List LstForCbx = new List{"AAA", "BBB", "CCC", "XXX", "YYY", "ZZZ"}; columnC combobox in DataGridComboBoxColumn not working. What wrong with my code?

    Read the article

  • WPF - Overlapping Custom Tabs in a TabControl and ZIndex

    - by Rachel
    Problem I have a custom tab control using Chrome-shaped tabs that binds to a ViewModel. Because of the shape, the edges overlap a bit. I have a function that sets the tabItem's ZIndex on TabControl_SelectionChanged which works fine for selecting tabs, and dragging/dropping tabs, however when I Add or Close a tab via a Relay Command I am getting unusual results. Does anyone have any ideas? Default View http://i193.photobucket.com/albums/z197/Lady53461/tabs_default.jpg Removing Tabs http:/i193.photobucket.com/albums/z197/Lady53461/tabs_removing.jpg Adding 2 or more Tabs in a row http:/i193.photobucket.com/albums/z197/Lady53461/tabs_adding.jpg Code to set ZIndex private void PrimaryTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.Source is TabControl) { TabControl tabControl = sender as TabControl; ItemContainerGenerator icg = tabControl.ItemContainerGenerator; if (icg.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) { foreach (object o in tabControl.Items) { UIElement tabItem = icg.ContainerFromItem(o) as UIElement; Panel.SetZIndex(tabItem, (o == tabControl.SelectedItem ? 100 : 90 - tabControl.Items.IndexOf(o))); } } } } By using breakpoints I can see that it is correctly setting the ZIndex to what I want it to, however the layout is not displaying the changes. I know some of the changes are in effect because if none of them were working then the tab edges would be reversed (the right tabs would be drawn on top of the left ones). Clicking a tab will correctly set the zindex of all tabs (including the one that should be drawn on top) and dragging/dropping them to rearrange them also renders correctly (which removes and reinserts the tab item). The only difference I can think of is I am using the MVVM design pattern and the buttons that Add/Close tabs are relay commands. Does anyone have any idea why this is happening and how I can fix it?? p.s. I did try setting a ZIndex in my ViewModel and binding to it, however the same thing happens when adding/removing tabs via the relay command. EDIT: Being a new user I couldn't post images and could only post 1 link. Images just show a picture of what the tags render as after each scenario. Adding more then 1 at a time will not reset the zindex of other recently-added tabs so they go behind the tab on the Right, and closing tabs does not correctly render the ZIndex of the SelectedTab that replaces it and it shows up behind the tab on its right.

    Read the article

  • WPF performance : Converters vs. Triggers

    - by Joachim Kerschbaumer
    hi there, i´m currently facing a problem where i have to set properties on a bunch of framework elements depending on some other properties. i wonder how triggers and converters compare when it comes to performance. Especially MultiTriggers and IMultiValueConverters. Is there any difference? google wasn't helpful so i thought maybe some of the guys over here at SO could bring in some light. thanks, j.

    Read the article

  • Webcam streaming in a WPF application

    - by Nebo
    I noticed few similar questions already, but didn't find exatly what I want. I'm trying to do the following. Have a client and server Webcam application. Server application is on a PC with a webcam connected to it and it streams the webcam output. Client application connects to a Server and shows the webcam video. What's the best and easiest way to to this? Are there any libraries or finished projects doing this?

    Read the article

  • WPF ObservableCollection CollectionView.CurrentChanged not firing.

    - by EL
    Hi folks, I have a problem with one of my ICollectionViews. The ICollectionView's CurrentChanged event i not firing. Please see my code below. XAML: <!-- Publication --> <TextBlock Name="tbkPublication" Text="{x:Static abConst:Print.tbkPublicationText}" Grid.Row="0" Grid.Column="0" Margin="3" ></TextBlock> <ComboBox Grid.Column="1" Grid.Row="0" Margin="3" Name="cmbPublication" BorderThickness="1" ItemsSource="{Binding Path=EnterpriseList}" DisplayMemberPath="Name" SelectedValuePath="Value" SelectedIndex="0" IsSynchronizedWithCurrentItem="True" /> <!-- Distribution Area Region --> <TextBlock Name="tbkDistributionArea" Text="{x:Static abConst:Print.tbkDistributionAreaText}" Grid.Row="1" Grid.Column="0" Margin="3" ></TextBlock> <ComboBox Grid.Column="1" Grid.Row="1" Margin="3" Name="cmbDistributionArea" BorderThickness="1" ItemsSource="{Binding Path=ZonesList}" DisplayMemberPath="Name" SelectedValuePath="Value" SelectedIndex="0" IsSynchronizedWithCurrentItem="True" /> AND C# (ViewModel) #region Properties public ObservableCollection<GenericNameValuePair<int, string>> EnterpriseList { get { return _abEnterpriseList; } set { _abEnterpriseList = value; } } public ObservableCollection<GenericNameValuePair<int, string>> ZonesList { get { return _abZonesList; } set { _abZonesList = value; } } #endregion private void InitCollections() { _collectionViewEnterprise = CollectionViewSource.GetDefaultView(EnterpriseList); _collectionViewZone = CollectionViewSource.GetDefaultView(ZonesList); //Replace if(_collectionViewEnterprise == null) throw new NullReferenceException("Enterprise collectionView is null."); if (_collectionViewZone == null) throw new NullReferenceException("Zone collectionView is null."); _collectionViewEnterprise.CurrentChanged += new EventHandler(OnCollectionViewEnterpriseCurrentChanged); _collectionViewZone.CurrentChanged += new EventHandler(OnCollectionViewZoneCurrentChanged); } Please help. Thanks in advance.

    Read the article

  • ObservableCollection is not updating Multibinding in C# WPF

    - by Decept
    I have a TreeView that creates all its items from databound ObservableCollections. I have a hierarchy of GameNode objects, each object has two ObservableCollections. One collections has EntityAttrib objects and the other have GameNode objects. You could say that the GameNode object represents folders and EntityAttrib represents files. To display both attrib and GameNodes in the same TreeView I use Multibinding. This all works fine in startup, but when I add a new GameNode somewhere in the hierarchy the TreeView is not updated. I set a breakpoint in my converter method but it's not called when adding a new GameNode. It seems that the ObservableCollection is not notifying the MultiBinding of the change. If I comment out the MultiBinding and only bind the GameNode collection it works as expected. XAML: <HierarchicalDataTemplate DataType="{x:Type local:GameNode}"> <HierarchicalDataTemplate.ItemsSource> <MultiBinding Converter="{StaticResource combineConverter}"> <Binding Path="Attributes" /> <Binding Path="ChildNodes" /> </MultiBinding> </HierarchicalDataTemplate.ItemsSource> <TextBlock Text="{Binding Path=Name}" ContextMenu="{StaticResource EntityCtxMenu}"/> </HierarchicalDataTemplate> C#: public class GameNode { string mName; public string Name { get { return mName; } set { mName = value; } } GameNodeList mChildNodes = new GameNodeList(); public GameNodeList ChildNodes { get { return mChildNodes; } set { mChildNodes = value; } } ObservableCollection<EntityAttrib> mAttributes = new ObservableCollection<EntityAttrib>(); public ObservableCollection<EntityAttrib> Attributes { get { return mAttributes; } set { mAttributes = value; } } } GameNodeList is a subclassed ObservableCollection

    Read the article

  • WPF DatePicker UpdateSourceTrigger PropertyChanged not working...

    - by user557352
    I am using MVVM and want to enable a button on text change of datepicker control.. XAML Code Binding on DatePicker SelectedDate="{Binding InactiveDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayDate="{Binding InactiveDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Binding on Button View Model Code I am using a DelegateCommand for button click View Model Delegate Initialization SubmitCommand = new DelegateCommand(OnSubmitRequested, AllowSubmit, Controller); The AllowSubmit implementation private bool AllowSubmit() { return InactiveDate != null; } InactiveDate Property implementation public DateTime? InactiveDate { get { return _inactiveDate; } set { _inactiveDate = value; SubmitCommand.RaiseCanExecuteChanged(); PropertyChanged(this, new PropertyChangedEventArgs("InactiveDate")); } } SubmitCommand.RaiseCanExecuteChanged() should enable the button once I enter any character on DateTimePicker but it is not happening.

    Read the article

  • WPF databind Image.Source in MVVM

    - by BrettRobi
    I'm using MVVM and am trying to databind the Source property of Image to my ViewModel in such a way that I can change the icon on the fly. What is the best pattern to follow for this? I still have the flexibility to change my ViewModel to suit, but I don't know where to start in either the xaml or ViewModel. To be clear, I don't want my ViewModel to know about the specific images (that's for the View to know), just the state that triggers different images. For now I have just two states, lets say Red and Green. Should I create an Enum property or a bool? And then how do I databind to switch the image source?

    Read the article

  • WPF DataContext does not refresh the DataGrid using MVVM model

    - by vikram bhatia
    Project Overview I have a view which binds to a viewmodel containing 2 ObserverableCollection. The viewmodel constructor populates the first ObserverableCollection and the view datacontext is collected to bind to it through a public property called Sites. Later the 2ed ObserverableCollection is populated in the LoadOrders method and the public property LoadFraudResults is updated for binding it with datacontext. I am using WCF to pull the data from the database and its getting pulled very nicely. VIEWMODEL SOURCE class ManageFraudOrderViewModel:ViewModelBase { #region Fields private readonly ICollectionView collectionViewSites; private readonly ICollectionView collectionView; private ObservableCollection<GeneralAdminService.Website> _sites; private ObservableCollection<FraudService.OrderQueue> _LoadFraudResults; #endregion #region Properties public ObservableCollection<GeneralAdminService.Website> Sites { get { return this._sites; } } public ObservableCollection<FraudService.OrderQueue> LoadFraudResults { get { return this._LoadFraudResults;} } #endregion public ManageFraudOrderViewModel() { //Get values from wfc service model GeneralAdminService.GeneralAdminServiceClient generalAdminServiceClient = new GeneralAdminServiceClient(); GeneralAdminService.Website[] websites = generalAdminServiceClient.GetWebsites(); //Get values from wfc service model if (websites.Length > 0) { _sites = new ObservableCollection<Wqn.Administration.UI.GeneralAdminService.Website>(); foreach (GeneralAdminService.Website website in websites) { _sites.Add((Wqn.Administration.UI.GeneralAdminService.Website)website); } this.collectionViewSites= CollectionViewSource.GetDefaultView(this._sites); } generalAdminServiceClient.Close(); } public void LoadOrders(Wqn.Administration.UI.FraudService.Website website) { //Get values from wfc service model FraudServiceClient fraudServiceClient = new FraudServiceClient(); FraudService.OrderQueue[] OrderQueue = fraudServiceClient.GetFraudOrders(website); //Get values from wfc service model if (OrderQueue.Length > 0) { _LoadFraudResults = new ObservableCollection<Wqn.Administration.UI.FraudService.OrderQueue>(); foreach (FraudService.OrderQueue orderQueue in OrderQueue) { _LoadFraudResults.Add(orderQueue); } } this.collectionViewSites= CollectionViewSource.GetDefaultView(this._LoadFraudResults); fraudServiceClient.Close(); } } VIEW SOURCE public partial class OrderQueueControl : UserControl { private ManageFraudOrderViewModel manageFraudOrderViewModel ; private OrderQueue orderQueue; private ButtonAction ButtonAction; private DispatcherTimer dispatcherTimer; public OrderQueueControl() { LoadOrderQueueForm(); } #region LoadOrderQueueForm private void LoadOrderQueueForm() { //for binding the first observablecollection manageFraudOrderViewModel = new ManageFraudOrderViewModel(); this.DataContext = manageFraudOrderViewModel; } #endregion private void cmbWebsite_SelectionChanged(object sender, SelectionChangedEventArgs e) { BindItemsSource(); } #region BindItemsSource private void BindItemsSource() { using (OverrideCursor cursor = new OverrideCursor(Cursors.Wait)) { if (!string.IsNullOrEmpty(Convert.ToString(cmbWebsite.SelectedItem))) { Wqn.Administration.UI.FraudService.Website website = (Wqn.Administration.UI.FraudService.Website)Enum.Parse(typeof(Wqn.Administration.UI.FraudService.Website),cmbWebsite.SelectedItem.ToString()); //for binding the second observablecollection******* manageFraudOrderViewModel.LoadOrders(website); this.DataContext = manageFraudOrderViewModel; //for binding the second observablecollection******* } } } #endregion } XAML ComboBox x:Name="cmbWebsite" ItemsSource="{Binding Sites}" Margin="5" Width="100" Height="25" SelectionChanged="cmbWebsite_SelectionChanged" DataGrid ItemsSource ={Binding Path = LoadFraudResults} PROBLEM AREA: When I call the LoadOrderQueueForm to bind the first observablecollection and later BindItemsSource to bind 2ed observable collection, everything works fine and no problem for the first time binding. But, when I call BindItemsSource again to repopulate the obseravablecollection based on changed selected combo value via cmbWebsite_SelectionChanged, the observalblecollection gets populated with new value and LoadFraudResults property in viewmodule is populated with new values; but when i call the datacontext to rebind the datagrid,the datagrid does not reflect the changed values. In other words the datagrid doesnot get changed when the datacontext is called the 2ed time in BindItemsSource method of the view. manageFraudOrderViewModel.LoadOrders(website); this.DataContext = manageFraudOrderViewModel; manageFraudOrderViewModel values are correct but the datagrid is not relected with changed values. Please help as I am stuck with this thing for past 2 days and the deadline is approaching near. Thanks in advance

    Read the article

  • WPF MenuItem.Command binding to ElementName results to System.Windows.Data Error: 4 : Cannot find so

    - by e28Makaveli
    I have the following XAML: <UserControl x:Class="EMS.Controls.Dictionary.TOCControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:EMS.Controls.Dictionary.Models" xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase" x:Name="root" > <TreeView x:Name="TOCTreeView" Background="White" Padding="3,5" ContextMenuOpening="TOCTreeView_ContextMenuOpening" ItemsSource="{Binding Children}" BorderBrush="{x:Null}" > <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Path=Children, Mode=OneTime}"> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <!--<ColumnDefinition Width="Auto"/>--> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <!--<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsVisible}"/>--> <ContentPresenter Grid.Column="0" Height="16" Width="20" Content="{Binding LayerRepresentation}" /> <!--<ContentPresenter Grid.Column="1" > <ContentPresenter.Content> Test </ContentPresenter.Content> </ContentPresenter>--> <TextBlock Grid.Column="2" FontWeight="Normal" Text="{Binding Path=Alias, Mode=OneWay}" > <ToolTipService.ToolTip> <TextBlock Text="{Binding Description}" TextWrapping="Wrap"/> </ToolTipService.ToolTip> </TextBlock> </Grid> <HierarchicalDataTemplate.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Path=Children, Mode=OneTime}"> <!--<DataTemplate>--> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <CheckBox VerticalAlignment="Center" IsChecked="{Binding IsVisible}"/> <ContentPresenter Grid.Column="1" Content="{Binding LayerRepresentation, Mode=OneWay}" /> <TextBlock Margin="0,1,0,1" Text="{Binding Path=Alias, Mode=OneWay}" Grid.Column="2"> <ToolTipService.ToolTip> <TextBlock Text="{Binding Description}" TextWrapping="Wrap"/> </ToolTipService.ToolTip> </TextBlock> </Grid> <!--</DataTemplate>--> </HierarchicalDataTemplate> </HierarchicalDataTemplate.ItemTemplate> </HierarchicalDataTemplate> </TreeView.ItemTemplate> <TreeView.ContextMenu> <ContextMenu> <MenuItem Name="miRemove" Header="Remove" Command="{Binding ElementName=root, Path=RemoveItemCmd, diagnostics:PresentationTraceSources.TraceLevel=High}"> <MenuItem.Icon> <Image Source="../images/16x16/Delete.png"/> </MenuItem.Icon> </MenuItem> <MenuItem Header="Properties" Command="{Binding ElementName=root, Path=GetItemPropertiesCmd}"/> </ContextMenu> </TreeView.ContextMenu> </TreeView> </UserControl> Code behind for this UserControl has two ICommand properties with names: RemoveItemCmd and GetItemPropertiesCmd. However, I get System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=root'. BindingExpression:Path=RemoveItemCmd; DataItem=null; target element is 'MenuItem' (Name='miRemove'); target property is 'Command' (type 'ICommand') System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=root'. BindingExpression:Path=GetItemPropertiesCmd; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'Command' (type 'ICommand') when UserControl is constructed. Why is this and how do I resolve?

    Read the article

  • WPF TextBox.SelectAll () doesn't work

    - by Zoliq
    Hi! I have used the following template in my project: <DataTemplate x:Key="textBoxDataTemplate"> <TextBox Name="textBox" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" Tag="{Binding}" PreviewKeyDown="cellValueTextBoxKeyDown"> <TextBox.Text> <MultiBinding Converter="{StaticResource intToStringMultiConverter}"> <Binding Path="CellValue" Mode="TwoWay"> <Binding.ValidationRules> <y:MatrixCellValueRule MaxValue="200" /> </Binding.ValidationRules> </Binding> <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type y:MatrixGrid}}" Path="Tag" Mode="OneWay" /> </MultiBinding> </TextBox.Text> </TextBox> </DataTemplate> I used this template to create an editable matrix for the user. The user is able to navigate from cell to cell within the matrix and I would like to highlight the data in the selected textbox but it doesn't work. I called TextBox.Focus () and TextBox.SelectAll () to achieve the effect but nothing. The Focus () works but the text never gets highlighted. Any help is welcome and appreciated.

    Read the article

  • WPF: How to autosize Path to its container?

    - by 742
    I have a Path that must resize to its StackPanel container. <StackPanel x:Name="TrackSurface"> <Path Fill="AliceBlue" Stroke="Black" StrokeThickness="1" Data="{StaticResource TranslateZ}"> </Path> </StackPanel> I think about using a transformation bound to the container but don't know how to it actually. Can someone give me hint?

    Read the article

  • WPF touchScreen ListBox control design

    - by pnb
    I need to allow the user to select the item in a listbox on mouse down and when the user drags up or down i need to scroll the items in listbox, since the user interacts with the listbox touch touch screen, i want some thing like the ipod behaviour. User should be able to touch/grab the item and drag it up or down to scroll the listbox.

    Read the article

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >