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

Changing brightness of window (Form)

$
0
0

Hi,
   I have a WPF application that have multiple forms/user controls. I would like reduce brightness of active form if form is ideal (No movement on the form) for 90 seconds and become dark gradually as time increases. I am using themes in the application and currently is it set to blue. Also I would like to add this functionality all forms being displayed.
  What is the best way to achieve this? I am using VB.Net , VS2013.

Thank you

Guy


opening WPF forms from Classic Windows forms

$
0
0
I have a legacy classic windows forms project. Some of my popup windows needs to be redone. Is there a way to open WPF forms from a classic windows form?

Certified Geek

ListViewItem tooltip

$
0
0

Hi!i have a problem.

This code works

<ListView.ItemContainerStyle><Style TargetType="ListViewItem"><Setter Property="ToolTip" Value="someTextHere"/></Style></ListView.ItemContainerStyle>

but this, no.  

<ListView.ItemContainerStyle><Style TargetType="ListViewItem"><Setter Property="ToolTip" Value="{Binding ArticuloSeleccionado.Descripcion"/></Style></ListView.ItemContainerStyle>

ArticuloSeleccionado.Descripcion is string.

progressing through the records of an ACCDB query using navigation buttons("Previous record", "Next record", etc) in C# with WPF

$
0
0

I have designed an ACCDB-based multi-table query.

I need to fill form textboxes from the records retrieved using this query.

I have created the WPF project, linking each textbox to a field within the query.

I have gotten as far as running the query, with one single record retrieved, filling the textboxes.

I need to create navigation buttons which will cause field values from the next and previous records within the query results to be displayed, replacing the values previously displayed with each click of the appropriate navigation button.

The only examples I can find relate to listboxes and scrolling up and down, rather than navigating through the records retrieved in a query with only one record displayed at a time.

This type of navigation capability is automatic in Windows Forms, and I would like to create the same functionality using WPF and C# in the Visual Studio 2012 environment.

What should the 'C#' event code look like?


Export/Add Datagrid to programmatically generated PowerPoint presentation

$
0
0

Hi All,

I would like to ask you, how could I export or add DataGrid from my app to the powerpoint presentation?

I know how to create an ppt, but I cannot find solution for export. 

Appreciate your suggestions

Thank you!


Mathh

Confusion...

$
0
0

Hi,

I have a control for which I activate a visual state on Mouse Enter to show it and activate another one to hide it in Mouse Leave.

The control has a ContextMenu on it and when I trigger the context menu using the right click and close the context I force a call to the visual state to hide the control but here's the confusion.  If I go back on the control (MouseEnter) it does nothing.  I have to leave it and enter it again so the normal process works.  Why the first time it doesn't work but the second time ? This is happening only if the mouse is still on the area of the control when closing the context menu. If the mouse is outside it works as normal.

I do check if the context menu is open in the MouseLeave of the control so I do not activate the state to hide it since when getting in the context menu I'm leaving the control.

I'll try to make a video to show this if it's not clear

Meanwhile here's the code :

private void CallCustomersButton_MouseEnter(object sender, MouseEventArgs e)
{
    VisualStateManager.GoToState(this, "ShowCustomers", true);
}
private void CallCustomersButton_MouseLeave(object sender, MouseEventArgs e)
{
    if(!lstCustomers.ContextMenu.IsOpen)
        VisualStateManager.GoToState(this, "ShowCustomersNormal", true);
}
private void CustomersContextMenu_Closed(object sender, RoutedEventArgs e)
{
    VisualStateManager.GoToState(this, "ShowCustomersNormal", true);
}


Drag and Drop (and re-order) to ListBox binded to XML

$
0
0
Would you please help me with this scenario:


On stage, 2 listboxes and a textbox.
1.The first listbox lists all the items available, the list is grouped by 'Type' and its source is a binded XML file (read only).
2.The second listbox list all the items the user has dropped into from ListBox#1 and it should read from an XML at start-up and save to it on quitting.
3.The textbox list the details of the currently selected item in ListBox#2



My knowledge (and search on internet ) allowed me to achieve binding, grouping with an expander and perhaps the first step to drag item (to be verified)..but I'm stucked at dropping AND re-ordering items on ListBox#2..then saving to the XML!!

Would you please help (even in c#..I'll try to do the translation) ? I join a graphic and the project file (with XML files inside) to help you help me! Thanks!!

Download project

The XAML

<Window x:Class="MainWindow"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"    xmlns:dat="clr-namespace:System.Windows.Data;assembly=PresentationFramework"    Title="MainWindow" Height="400" Width="525">    <Grid>        <Grid.Resources>            <DataTemplate x:Key="Resource3">                <Label Content="{Binding XPath=Name}"/>            </DataTemplate>            <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">                <EventSetter Event="ListBoxItem.PreviewMouseLeftButtonDown" Handler="s_PreviewMouseLeftButtonDown" />            </Style>            <Style x:Key="ListBoxItemStyle2" TargetType="{x:Type ListBoxItem}">                <Setter Property="AllowDrop" Value="true"/>                <EventSetter Event="ListBoxItem.PreviewMouseLeftButtonDown" Handler="s_PreviewMouseLeftButtonDown" />                <EventSetter Event="ListBoxItem.Drop" Handler="listbox_Drop"/>            </Style>        </Grid.Resources>        <Grid Name="Grid01">            <Grid.Resources>                <CollectionViewSource x:Key="cvsSystems" Source="{Binding XPath=System}">                    <CollectionViewSource.SortDescriptions>                        <scm:SortDescription PropertyName="@Type"/>                        <scm:SortDescription PropertyName="Name"/>                    </CollectionViewSource.SortDescriptions>                    <CollectionViewSource.GroupDescriptions>                        <dat:PropertyGroupDescription  PropertyName="@Type"/>                    </CollectionViewSource.GroupDescriptions>                </CollectionViewSource>            </Grid.Resources>            <ListBox ItemsSource="{Binding Source={StaticResource
cvsSystems}}" ItemTemplate="{StaticResource Resource3}"
SelectedValuePath="Name" IsSynchronizedWithCurrentItem="True"
HorizontalAlignment="Left" x:Name="ListBox1" Width="160"
ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
Margin="0,0,0,0">                <ListBox.GroupStyle>                    <GroupStyle>                        <GroupStyle.ContainerStyle>                            <Style TargetType="{x:Type GroupItem}">                                <Setter Property="Template">                                    <Setter.Value>                                        <ControlTemplate>                                            <Expander Header="{Binding Name}" IsExpanded="True">                                                <ItemsPresenter />                                            </Expander>                                        </ControlTemplate>                                    </Setter.Value>                                </Setter>                            </Style>                        </GroupStyle.ContainerStyle>                    </GroupStyle>                </ListBox.GroupStyle>            </ListBox>        </Grid>        <Grid Name="Grid02">            <Grid.Resources>                <CollectionViewSource x:Key="cvsPreferences" Source="{Binding XPath=System}">                    <CollectionViewSource.SortDescriptions>                        <scm:SortDescription PropertyName="@Type"/>                        <scm:SortDescription PropertyName="Name"/>                    </CollectionViewSource.SortDescriptions>                    <CollectionViewSource.GroupDescriptions>                        <dat:PropertyGroupDescription  PropertyName="@Type"/>                    </CollectionViewSource.GroupDescriptions>                </CollectionViewSource>            </Grid.Resources>            <ListBox ItemsSource="{Binding Source={StaticResource
cvsPreferences}}" ItemTemplate="{StaticResource Resource3}"
SelectedValuePath="Name" IsSynchronizedWithCurrentItem="True"
HorizontalAlignment="Left" x:Name="ListBox2" Width="160"
ItemContainerStyle="{DynamicResource ListBoxItemStyle2}"
Margin="170,0,0,0"/>            <Button Content="Save" Height="23"
HorizontalAlignment="Left" Margin="385,320,0,0" Name="Button1"
VerticalAlignment="Top" Width="75" />        </Grid>        <TextBox DataContext="{Binding SelectedItem,
ElementName=ListBox2}" Text="{Binding
UpdateSourceTrigger=PropertyChanged, XPath=Detail}" Margin="340,0,0,0"
x:Name="TextBox1" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="160"/>    </Grid></Window>


The VB code

Imports System.IO
Imports System.Xml
Class MainWindow    Dim sysdata As XmlDocument = New XmlDocument()    Dim prefdata As XmlDocument = New XmlDocument()    Dim systemdata As XmlDataProvider = New XmlDataProvider()    Dim preferencedata As XmlDataProvider = New XmlDataProvider()    Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded        'Initialisation XML        sysdata.Load(System.AppDomain.CurrentDomain.BaseDirectory & "Systems.xml")        prefdata.Load(System.AppDomain.CurrentDomain.BaseDirectory & "Preferences.xml")        systemdata.Document = sysdata        preferencedata.Document = prefdata        systemdata.XPath = "Systems"        preferencedata.XPath = "Systems"        Grid01.DataContext = systemdata        Grid02.DataContext = preferencedata    End Sub    Private Sub s_PreviewMouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)        If TypeOf sender Is ListBoxItem Then            Dim draggedItem As ListBoxItem = TryCast(sender, ListBoxItem)            DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Copy)            draggedItem.IsSelected = True        End If    End Sub    Private Sub listbox_Drop(ByVal sender As Object, ByVal e As DragEventArgs)    End Sub    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click        preferencedata.Document.Save(System.AppDomain.CurrentDomain.BaseDirectory & "Preferences.xml")    End Sub
End Class


Add DataColumn from DataTable to DatGrid in WPF

$
0
0

I have a DataGrid that need to be filled with value from Database and i need the first column to be populated into datagrid.

Here is my backend code

public string Get_vendor_like(Model_Vendor mv)
       {
           SqlConnection con1;
           SqlCommand cmd1;
           SqlDataAdapter sd;
           try
           {
               string vname = mv.ven_cname + "" + "%";
               con1 = new SqlConnection(getconnection.connectionstring);
               con1.Open();
               cmd1 = new SqlCommand("SELECT [Company Name] as cname,[Vendor Address],[Vendor Phone],[LANDLINE] ,[VDate Added],[EMAIL],[VENDOR NUMBER] AS VNUM  FROM [Vendor] where [Company Name] like @vname", con1);
               cmd1.Parameters.AddWithValue("@vname", vname);
               sd = new SqlDataAdapter(cmd1);
               mv.Vendor_Table = new DataTable();
               sd.Fill(mv.Vendor_Table);
               foreach (DataColumn dr in mv.Vendor_Table.Columns)
               {
                   datagrid_editpo.Items.Add(dr.Table.Columns[0].ToString());
               }
return "0";
           }
           catch (Exception ee)
           {
               return mv.ret_val = ee.Message;
           }
       }

Corresponding XAML

<DataGrid x:Name="datagrid_editpo" IsTextSearchEnabled="True" IsTextSearchCaseSensitive="False"
                                  AutoGeneratingColumn="Customer_Grid_AutoGeneratingColumn_1" CanUserAddRows="False"
                                  ColumnHeaderHeight="30" FontWeight="Medium" ColumnWidth="*"  AutoGenerateColumns="False"
                                  CanUserResizeColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.IsDeferredScrollingEnabled="True"
                                  HorizontalAlignment="Left"  VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}"
                                  AlternatingRowBackground="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}"
                                  GridLinesVisibility="None" Height="683" Margin="0,33,-2,0"  MouseLeftButtonUp="datagrid_editpo_MouseLeftButtonUp" Width="428"><DataGrid.Columns><DataGridTextColumn Binding="{Binding cname}" IsReadOnly="True" Header="Vendor" /></DataGrid.Columns></DataGrid>

Please suggest me a solution for this,

Thanks,


Winform's DataGridView equivalent in WPF for .net 3.5

$
0
0

Hi,

I did some reasearch to find DataGridView equivalent control which can perform all the below mentioned functionalites but i could not find it for .Net 3.5.

· Resize columns: hover over the end of a header, then click and drag.

· Reorder columns: click on a column header and drag over a different area.

· Auto-sort data in a column: click on a column header and the items in the column will toggle from ascending to descending

· Multi-column sorting: SHIFT + click on multiple column headers

· Selection: Default mode is FullRow and multi-row selection

I tried with ListView but we can achieve the basic functionalites with it and not the ones mentioned above. Please someone let me know which control i can use so as to achieve the above functionalities in WPF.

Thanks in advance.


Chetan Rajakumar

How to get filtered data from ICollectionView in WPF?

$
0
0

Hello,

I have applied filtered on ICollectionView. But still I didn't get the filtered collection.

      List<Customers> list = new List<Customers>();
      list.Add(new Customers() { Country= "USA", City = "NewYork", Amount = 10 });
      list.Add(new Customers() { Country= "England", City = "London", Amount = 20 });

      list.Add(new Customers() { Country= "USA", City = "NewYork", Amount = 10 });
      list.Add(new Customers() { Country= "England", City = "Oval", Amount = 20 });

       ICollectionView collectionView = CollectionViewSource.GetDefaultView(list);

       //Predicate is custom filter expression, it contain City='NewYork' as Expression

      collectionView.Filter = new Predicate<object>(predicate);   

     IEnumerable filteredsource = collectionView.SourceCollection; //It returns all the items. I need only filtered  Items

     How to get filtered items from ICollectionView?                                                                                                                          

       Please do needful.

Thanks in advance

[WPF] Multilanguage application

$
0
0

Hi,
maybe this question is a replic of other questions present in this forum, but what is the best way for create an multilanguage app?

I'm following this tutorial, what do you think about this?

1) How can I set a default language in App.xaml
2) The method SetLanguageDictionary() should be inserted in each page or only in MainWindows.xaml?

You may report me a good guide or a tutorial?

Thanks.

 

How do i split a line in a csv file and populate a combobox and a textbox with the parts

$
0
0

What I'm trying to do is split the line and fill a combobox and with the selecteditem and the textbox with the value of the combobox selecteditem which is the second part of the line split.

Thanks in advance for the help or suggestions.

WPF Graph (Graph as collection of nodes and edges) Design and Drawing Panel

$
0
0

Hi,

I plan to work on a GUI similar to ndepend panel for dependency graphs. I was looking for digging deeper in this aspect handling 1000s of simultaneous object on the panel forming a dependency graphs (or digraphs). Please help me find some research material in this direction.

Thank you,

Best Regards,

Mandeep

Data Grid Development

$
0
0

Hello,

i develop the UI framework, i need to develop a data grid component to use in the wpf project and asp.net project in the same time, any idea ? 


Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

Crystal Report probelm in wpf.

$
0
0

Hii everyone

I am using VS2008 and i want to use crystal report in my project ,so i added crystal report file and done everything correctly but when i am building my project i am getting the error as follows :

Error :Assembly 'SAPBusinessObjects.WPF.Viewer, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' uses 'CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' which has a higher version than referenced assembly 'CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'    c:\Users\suryakant.FOCUSNETCOM\Downloads\SAPBusinessObjects.WPF.Viewer.dll    WpfEmpApps(22Jan)

Can any body hep me how to solve this dll problem,if possible provide me the link for folowing dll :

  • SAPBusinessObjects.WPF.Viewer.dll
  • SAPBusinessObjects.WPF.ViewerShared.dll


S.K Nayak


How to bind a WrapPanel's items with different width to respective Grid's ColumnWidth??

$
0
0

I have a Grid which has two columns. Inside the grid there will be WrapPanel which starts from column 0 and has columnspan of 1. This WrapPanel has two children. I want one children's width to be the width of col0 and other to be the width of col1. I have tried something(code below) but it is not working.[Initially I implemented this without wrappanel that is my grid will have two columns,one column takes 60% of the total width and also has minimum width, other column  takes 40% of the total width.So everything is fine.But when I resize my window I want the second column to get wrapped to the bottom of the 1st column.So I added wrappanel].

The following code explains well:

<Grid Grid.Row="1" Margin="0,20,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="6*"></ColumnDefinition>
                                <ColumnDefinition Width="4*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <WrapPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2"  HorizontalAlignment="Left" VerticalAlignment="Top">
                                <StackPanel Margin="0" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid}}, Path=ColumnDefinitions[0].ActualWidth}">
          <Button Margin="0,3,0,0" Style="{DynamicResource StartPage.RSS.TitleTextStyle}" FontSize="13"/>
                                       <Button Margin="0,3,0,0" Style="{DynamicResource StartPage.RSS.TitleTextStyle}"/>
</StackPanel>
                                <StackPanel Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Grid}}, Path=ColumnDefinitions[1].ActualWidth}">
                                    <TextBlock Foreground="{DynamicResource VsBrush.ToolWindowText}"></TextBlock>
                                    <Button Margin="0,5,0,0" Style="{DynamicResource StartPage.RSS.TitleTextStyle}"/>
                                </StackPanel>
                            </WrapPanel>
 </Grid>



Storing encrypted username and password along with the Key into Windows Keystore

$
0
0

I have a WPf application and I need to allow the user to enter the username and password. Username and Password should be encrypted and store them with the key into the windows Keystore. I used the Cryptography class to encrypt the username and password but I am not sure how to store them in the Windows Key Store.

This login is used for configuration purpose only. User enters  and  it is saved into the clients machine. As long these credentials are correct, we are going to allow this machine to call another API to download files.

I would really appreciate for any sample code. Basically, I need to store them in the registry and be able to call them to verify.

binding POCO navigation property as DataGridComboBoxColumn using Mvvm

$
0
0

I have attached my sample project on this url. It is based on this article. I have extended the project to ask my question better. my problem is for OrdersView.xaml. there I would like to use DataGridComboBoxColumn and it should bind Customer navigation object on Orders. as It is difficult to copy paste whole and entire classes here, I added the project. What am I doing wrong? what is the logic of binding navigation properties on xaml in general?



"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."


Set window min width and min height with SizeToContent

$
0
0

Hi everyone,

I'm currently making an application which contains 1 window and many similar formatted page (width = 500, height = 600).

How can I make the window fit to content and cannot be resized to be smaller but bigger.

Thank you :)

Which design pattern is better for WPF application

$
0
0

Hi,

I want to develop an application in wpf but not able to decide which design pattern to use. 

n tier, MVVM, MVC.....which is better? every patterns has advantages and disadvantages.

Application should be easy to maintain and add new functionality easily later on.

But MVVM looks too complex. Please share your view and suggestions.

Thanks

Viewing all 18858 articles
Browse latest View live


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