Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

Editable Listbox in WPF

$
0
0

Friends,

I want to develop editable listbox in wpf, that is on click/double click of any item in the listbox should change to Textbox/editable mode that should be shown with same text what was selected.  then i modify the text on textbox,  on press of escape i have to restore the value, and on enter i have to commit the value.  

I'm trying to implement all possible code in XAML itself as much as possible because i  want to reduce code in code behind.  Please anyone guide me. Thanks 


Thanks - Ravi


WPF Security: Role vs Claims

$
0
0

Hi, 

I want to develop a new WPF application with specifi user security settings, establising different permissions in operations like read, upate an delete.

For example, only the user that creates a client can modify it later.

How can I implement this with role or claims based security. Can anyone give me any example?

Thanks

Showing just the top line in a combobox

$
0
0
I've got to show product information in a WPF combobox. That's easily done in a datatemplate. I'll make the data template show the information in about 3 lines. The first line will have the product name. What I'd like to know is if there is a way to only show the top line when the combobox isn't expanded. Is that possible to do in WPF? If so, how is that done?

Rod

Flow for screen display

$
0
0

Right now I have two WMF forms:

  MainWindow - contains a menubar with drop down windows; initially it sends execution to the Settings form to do initialization routines, then returns and displays the menubar.  At this point one option on the menu will send execution to settings for the user to enter preferences.

  Settings - does some initialization routines and maybe allow user to enter preferences (I'm not quite sure if this is the right place).

I want the menubar to remain on the screen when the user clicks the option to changes preferences.  At this point the preferences will have two tabs.  Before I go any further I want to understand this better so I can arrange the code where it should go and nt have to redo it later.

Is this an acceptable setup or should the initialization routines go in some other type of file?  Do I set up both preferences tabs in the same WPF file or do they need to be in separate WPF files?

How to show only two menu items("Move" & "Close") in the system menu of WPF window?

$
0
0

Hi,

When I created a WPF window, below is the image of System Menu.

I want only "Move" & "Close" menu items to be displayed in the system menu.

Could anyone please help me how can I create a dialog with only two menu items("Move"&"Close") in the system menu.

Regards,

Siva


SivaV

HttpContext with WPF

$
0
0
Hello,
Our company is migrating an application from Silverlight 5.0 to WPF 4.5. In the process of migrating we have implemented Open RIA Services . And everything works great with Silverlight. However, when using RIA services with WPF we lose HttpContext.Current settings from call to call. Is there a way to persist HttpContext in WPF for the “session”, similar to what happens with Silverlight? (i.e, can we use HttpContext.Current to save settings from call to call?)

wpf c# richtextbox is there a way to set vertical writing in the richtextbox and switch back to horizontal writing

$
0
0

wpf c# richtextbox   is there a way to set vertical writing in the richtextbox and switch back to horizontal writing

Thanks for your help

Mike Sobol

Copy to Clipboard from CollectionViewSource

$
0
0

Hi,

I'm using Collectionviewsource to bind data to DataGrid. I don't want to use DataGrid object in ViewMode. How can I copy data to clipboard from CollectionviewSource directly?

Please suggest.


c# wpf scroll synchronization between two treeviews when virtulisation is enabled

$
0
0

Hi,

I have a compare application in wpf , where in I can compare the contents of nodes in leftTree and RightTree.

I have wpf user control with two treeview's displayed side-by-side. I would like to view more then 800k nodes in the treeview. I have enabled virtulization and added logic so that I can bringIntoView any far away node in the tree by creating virtulized panel.

I also need to synchronize the scroll bar's for both the tree's.

But I am unable to synchronize the scroll bars, if virtulisation is enabled. The scroll position for both the tree's get confused.

Could anyone help me on this.

Thanks

Sunitha

WPF Datagrid Checkbox column Binding in MVVM

$
0
0

Hi All,

I have a WPF application which is following MVVM pattern. In view, I have a datagrid with several columns including a checkbox column. The header of this checkbox column includes a checkbox. On selecting and deselecting of this checkbox, all the checkboxes in checkbox column should gets selected and deselected respectively. User can also select or deselect a checkbox individually for a record. 

I am using ObservableCollection for datagrid binding which is a collection of StockItem object. This StockItem object/entity doesnot have any property for this checkbox column binding whereas it has properties for all other columns to bind. I don't wish to create a new entity for this checkbox column only. I want all the selected records in an observablecollection which is itself a collection of StockItem object/entity in viewmodel for further processing.  

So please let me know how to implement this functionality asap.

Regards,

Pratham

Displaying DirectX Content in WPF with D3DImage: How does D3DImage.SetBackBuffer() Work?

$
0
0

I have an image element in my WPF application that uses a D3DImage to render DirectX content. On the DirectX side I render everything to a Texture2D using SharpDX (a C# DirectX wrapper), but I'm not sure how to convert the rendered texture to a D3DImage.

I found the D3DImage.SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer)method, but that requires the texture to be a DXGI Surface. Here's the code I'm working with:

// renderTexture is a Texture2D that serves as the renderTarget for the DirectX content// d3dimg is the D3DImage that WPF uses

d3dimg.Lock()
d3dimg.SetBackBuffer(D3DResourceType.IDirect3DSurface9,
                     renderTexture.QueryInterface<Surface>().NativePointer);
d3dimg.Unlock();

But for some reason, the SetBackBuffer function call throws an exception saying that the "specified cast is not valid," even though I'm not doing any casts here (as far as I can see). What am I doing wrong? I think I must be providing a pointer to the wrong type for the second argument, but I'm not sure what that parameter expects.

Hosting exe in WPF

$
0
0

Hello folks,

I want to host the League of Legends game inside wpf user control. I have implemented a simple logic. It works fine with notepad.exe but it doesn't work with the game instance. Pretty tricky task.

Any advice would be most welcome. 

Repaint Issue when mixing WPF and WinForms on some PCs

$
0
0

Hello,

I have a strange problem with WPF and WinForms interop when I use scrolling (seems to be another airspace problem):

<Here should be a picture. Since I am new in the forum I cannot post it.>

You can see that the red border is not repainted after I scroll my buttons.

This is my WPF code:

<Border Padding="20"><Border Background="Red" Padding="5"><WindowsFormsHost x:Name="formsHost"><wfdx:LayoutControl x:Name="lc"></wfdx:LayoutControl></WindowsFormsHost></Border></Border>

The buttons are added programatically.

The LayoutControl is from DevExpress and is implemented with WinForms. Thus I have a WPF application which hosts a WinForms Layout Control which contains WinForm buttons.

The repaint issue you can see above only ocurrs in the following conditions:

1. Windows Aero Design is switched on

2. Enable desktop composition is checked (in Performance Options/Visual Effects)

3. Use two screens in "extending" mode

In all other cases the rendering problem does not appear. It also seems to depend on the used PC. I can see the problem with some HP laptops when I met the conditions above but on other laptop types I cannot see it even when all three conditions are met.

Does anyone have an idea what's the problem?

Best regards,

Thomas

Programmatically add Tigger and Setter to control

$
0
0

I am trying to implement this type of styling, http://www.wpf-tutorial.com/tabcontrol/styling-the-tabitems/; however, the tabs that we utilize is dynamically created, so this would need to be added to when the tab item was created at runtime.  

I need help understanding how to take the xaml process and translate it into a code behind process.

Thank you,


Robert Johnston

WPF TabControl

$
0
0

I have check some values before I selecting new tabitem and if check is false I wont show message and stay it old tabitem

How I can stay it old tabcontrol. WPF TabControl does't have event deselecting. How I can cancel selecting new tabitem.


Items collection must be empty before using ItemsSource

$
0
0

I asked a question previous, Showing just the top line in a combobox. That question was answered, but now I've got a new one which is directly related to it. In that previous question Li Wang answered with some code examples, which I've tried to implement, but I'm getting an error that says, "Items collection must be empty before using ItemsSource". I've not encountered this before nor seen it elsewhere. And at least as far as I understand how it works, I don't see why I'm getting that. I thought that the ItemsSource of my ComboBox was empty before I filled it. Here is the XAML for the combobox:

<ComboBox x:Name="cmbProducts"
		  ItemsSource="{Binding ProductsList}"
		  IsEditable="False"
		  Grid.Row="8"
		  Grid.Column="1"
		  Margin="6,0,0,3"
		  SelectedValue="{Binding OrderLine.Product_ID}"><common:ComboBoxItemTemplateSelector><common:ComboBoxItemTemplateSelector.SelectedTemplate><DataTemplate><TextBlock Text="{Binding Product_Name}" /></DataTemplate></common:ComboBoxItemTemplateSelector.SelectedTemplate><common:ComboBoxItemTemplateSelector.DropDownTemplate><DataTemplate><DockPanel LastChildFill="True"
						   Width="500"><TextBlock Text="{Binding Product_Name}"
							   DockPanel.Dock="Top"
							   FontSize="15"
							   Padding="5"
							   Background="#2288C6"
							   Foreground="White"
							   TextWrapping="Wrap"
							   Width="500"
							   HorizontalAlignment="Left" /><TextBlock Text="{Binding Description}"
								TextWrapping="Wrap"
								Padding="3"
								DockPanel.Dock="Top"
								FontWeight="Bold"
								HorizontalAlignment="Left" /><Grid Margin="3,0"
						  HorizontalAlignment="Left"><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition /><ColumnDefinition Width="10" /><!-- used for separation between the "first" column and the "second" column --><ColumnDefinition /><ColumnDefinition /></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition /><RowDefinition /></Grid.RowDefinitions><TextBlock HorizontalAlignment="Left">Supplier:</TextBlock><TextBlock Text="{Binding Last_Supplier}"
								   HorizontalAlignment="Left"
								   TextWrapping="Wrap"
								   FontWeight="Bold"
								   Margin="3,0,0,0"
								   Grid.Column="1" /><TextBlock Grid.Column="3"
								   Margin="3,0,0,0"
								   HorizontalAlignment="Left">SKU:</TextBlock><TextBlock Text="{Binding SKU}"
								   Grid.Column="4"
								   HorizontalAlignment="Left"
								   Margin="3,0,0,0"
								   FontWeight="Bold" /><TextBlock Grid.Row="1"
								   HorizontalAlignment="Left">Cost:</TextBlock><TextBlock Text="{Binding Current_Price, StringFormat=C}"
								   HorizontalAlignment="Left"
								   Grid.Row="1"
								   Grid.Column="1"
								   Margin="3,0,0,0"
								   FontWeight="Bold" /><TextBlock Grid.Row="1"
								   Grid.Column="3"
								   Margin="3,0,0,0"
								   HorizontalAlignment="Left">Unit:</TextBlock><TextBlock Text="{Binding Sales_Unit}"
								   HorizontalAlignment="Left"
								   Grid.Row="1"
								   Grid.Column="4"
								   Margin="3,0,0,0"
								   FontWeight="Bold" /></Grid></DockPanel></DataTemplate></common:ComboBoxItemTemplateSelector.DropDownTemplate></common:ComboBoxItemTemplateSelector></ComboBox>

For what it's worth, here's what I've got for the ProductsList in my VM:

//defined at the class level
public List<Product> ProductsList { get; set; }


//this method is called from the VM's constructors (I've got 2 constructors)
private void GetAllProducts()
{
	ProductsList = App.MainDataContext.Products.OrderBy(p => p.Product_Name).ToList();
}

Now finally here's the error message I'm getting:

System.InvalidOperationException was unhandled by user code
   HResult=-2146233079
   Message=Items collection must be empty before using ItemsSource.
   Source=PresentationFramework
   StackTrace:
        at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value, Func`2 GetSourceItem)
        at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
        at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
        at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
        at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
        at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
        at System.Windows.Data.BindingExpression.Activate(Object item)
        at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
        at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
        at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
        at MS.Internal.Data.DataBindEngine.Run(Object arg)
        at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
        at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
        at System.Windows.ContextLayoutManager.UpdateLayout()
        at System.Windows.UIElement.UpdateLayout()
        at System.Windows.Interop.HwndSource.SetLayoutSize()
        at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
        at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
        at System.Windows.Window.SetRootVisual()
        at System.Windows.Window.SetRootVisualAndUpdateSTC()
        at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
        at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
        at System.Windows.Window.CreateSourceWindowDuringShow()
        at System.Windows.Window.SafeCreateWindowDuringShow()
        at System.Windows.Window.ShowHelper(Object booleanBox)
        at System.Windows.Window.Show()
        at CoreFramework.UserControls.CoreHomeView.ReceiveOpenViewMessage(OpenViewMessage message) in D:\Src\CoreFramework\CoreFramework\UserControls\CoreHomeView.xaml.cs:line 56
   InnerException:

Rod

DependencyProperty on Behavior updated in trigger

$
0
0

In my WPF application I have a Behavior, in the Behavior I have a dependency property.

That Behavior is attached to a control within an ItemTemplate of a ListBox.

On the ItemTemplate there is a DataTrigger with Binding to IsSelected of the ListBoxItem.

In the DataTrigger I have a setter for the dependency property of the Behavior.

This is giving me an error that it doesn't recognize the name I gave to the Behavior.

Can someone help me understand why?

MediaElement and Rotation tag

$
0
0

Windows 10, .Net 4.5.1

When MediaElement open video with Rotation tag, it ignores it and play video upside down. On Windows 7 Windows Media Player has same behavior, but Windows Media Player from Windows 10 can play it normally. Is MediaElement just using some old version of Media Player component?

Video properties (Media Player Classic)

Bind Collection of INotifyPropertyChanged list to datgrid in WPF

$
0
0

Hi All,

In my WPF application i have one grid which i need to Bind different collection.

To make it generic i  have binded INotifyPropety Changed Collection to grid but all the columns are overlapping on one another.

Below is my collecction.

Any Suggestion would be of great help.

        private ObservableCollection<INotifyPropertyChanged> lstFilteredRecords { get; set; }

        public ObservableCollection<INotifyPropertyChanged> LstFilteredRecords
        {
            get { return lstFilteredRecords; }
            set
            {
                lstFilteredRecords = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("LstFilteredRecords"));
                }
            }
        }



Arjun

Set Selected Item to Null in Listbox

$
0
0

Hi All,

I have list in my WPF App.. where i change the list item source on TAB selection changes..

I need to set Selected item to null when i change the tab.

Currently first item of the list is getting selected when i change the item source of listbox.

Am Using MVVM.

        private ObservableCollection<ShortCuts> lstShortCuts { get; set; }
        public ObservableCollection<ShortCuts> LstShortCuts
        {
            get { return lstShortCuts; }
            set
            {
                lstShortCuts = value;
                if (PropertyChanged != null)
                {

                    PropertyChanged(this, new PropertyChangedEventArgs("LstShortCuts"));
                }
            }
        }

 private ShortCuts selectedShortCut { get; set; }
        public ShortCuts SelectedShortCut
        {
            get { return selectedShortCut; }
            set
            {


                    selectedShortCut = value;
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs("SelectedShortCut"));
                    }

                    if (SelectedShortCutChanged != null && SelectedShortCut != null)
                    {
                        SelectedShortCutChanged(this, new GenericEventArgs<ShortCuts>(SelectedShortCut));
                    }

            }
        }

<CollectionViewSource x:Key="shortCutGrouping" Source="{Binding LstShortCuts}"><CollectionViewSource.GroupDescriptions><PropertyGroupDescription PropertyName="Group" /></CollectionViewSource.GroupDescriptions></CollectionViewSource><ListBox ItemTemplate="{StaticResource ShortCutLinkDataTemplate}" Background="Transparent" Grid.Row="1" BorderBrush="Transparent" ItemsSource="{Binding Source={StaticResource shortCutGrouping}}" Margin="5,0,5,5" SelectedItem="{Binding SelectedShortCut,Mode=TwoWay}"/>
Any Suggestion would be of great Help


Arjun

Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>