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

What's the Future for XBAP Apps (Wpf Web Applicacions)?

$
0
0

Discussion topic:

What's the Future for XBAP Apps (Wpf Web Applicacions)?

The question is simple as that.

Taking in mind the all new revolutions occurring in .net Framework now-a-days, does this kind a apps (hosted only by Internet Explorer) be removed some time soon? 

Thanks!


-- Jorge_M_P


WPF + Prism + MVVM

$
0
0

Deal all

I start to study PRISM as I need to build a Composite UI based on a customer requirement.

From that point I go through getting started sample and get idea about architecture to setup.

In traditional WPF application we are using MVVM Light tool kit and we have a set of ready library which require common functionalities for our application.

In order to be able to reuse such library in our Prism study approach, does MVVM Light tool kit can be used instead of the default MVVM pattern explain in Prism ?

In our apps we use MVVM Light messaging approach to communicate between view and view model.

thanks for advise

regards

ComboBox mismatch

$
0
0

I have a WPF app with ComboBoxes. Each ComboBox has an item source with items to selected from. I load my main record and I try to bind main record to the selected value in ComboBox

SelectedValue="{Binding Path=opportunity.CaptureLead,Mode=TwoWay}"

Often there is a mismatch between my record and the item source. Are there any options for handling the ComboBox mismatch? I need an error handler. I have  a legacy system and I will have a lot of mismatches.

 


Certified Geek

IMultiValueConverter ConvertBack

$
0
0

The iMultiValueConverter is wonderful for getting hold of the ItemsSource. I use this converter for a ComboBox.
Unfortunately I don't know how to ConvertBack. The examples I find on the Internet does not work for me.
What can I do? 

public class MultiConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string selectedValue = values[0] as string;
            List<string> itemsSource = values[1] as List<string>;
            if (selectedValue != null && itemsSource != null)
            {
                if (!itemsSource.Contains(selectedValue))
                {
                    itemsSource.Add(selectedValue);
                }
            }
            return selectedValue;
        }
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }


Certified Geek


How to define a delegate that uses ref and generic arguments?

$
0
0

I've got a problem where a method can only be called from a foreground thread because it affects UI elements but sometimes a background worker needs to call it. I'd normally address the issue by detecting the cross thread access and, if so, calling a delegate to get on the foreground thread. In this case, however, the method to be invoked is a generic method that also uses the ref keyword and I'm having trouble getting the syntax just right.

Here's the method's definition:

protected virtual bool SetProperty<T>( ref T storage, T value, string propertyName = null );

Here's the code into which I'm trying to fit the thread transition:

protected override bool SetProperty<T>( ref T storage, T value, string propertyName = null ) { bool bReturn = false; System.Windows.Application app = System.Windows.Application.Current; if (app != null) { if (app.Dispatcher.CheckAccess()) {             // On foreground thread. Safe to invoke base SetProperty().
bReturn = base.SetProperty<T>( ref storage, value, propertyName ); } else { // On background thread. Must transition to foreground thread and call // SetProperty with the same args again.
// This is where the delegate/Lambda expression needs to be inserted. } } return bReturn; }



Richard Lewis Haggard

Grid being the wrong size when being filled with DynamicResource

$
0
0

Im currently building an app, and I wanted it to be multilingual. As such I put all the strings in a StringResources.xaml file (for english texts) that contain entries such as the following:

<system:String x:Key="ID">ID</system:String>

I then call this function in the initialization of my MainWindow to set the appropriate resource dictionary.

 private void SetLanguageDictionary()
 {
        ResourceDictionary dict = new ResourceDictionary();

        if (French)
            dict.Source = new Uri("..\\Resources\\StringResources.fr-CA.xaml", UriKind.Relative);
        else
            dict.Source = new Uri("..\\Resources\\StringResources.xaml", UriKind.Relative);

        this.Resources.MergedDictionaries.Add(dict);
 }

The problem im having (which im not 100% sure if its related to this) is that when my program runs, the grid size is set to have 3 columns of size 1* each, but the label takes up about 60% of all the space. Once I try to resize the window, the grid magically changes the column size and everything is fine.

Here are the pictures. 

http://imgur.com/fWSl6km,aY5jY6T#0

You can see how in the first one, the text takes up a lot of space, while after just resizing 1 pixel in width or height, its as if the window is redrawn and the grid goes to its proper size. Anybody know how to overcome this?

VB Marshal size problem

$
0
0

Hi!

I become back the error that the size of my Array is to big...

How can i fit it?

Here is the Array with the Problem:

<StructLayout(LayoutKind.Sequential)> Public Structure VBSATZFREITEXTSUCHE

        ' *******************************************************************************************************
        ' Such Tabelle (max. 100 Spalten)
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=100)> Public SuchArray() As WPFStandardSuchTabelle<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=10)> Public SuchAnzahl As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=81)> Public SuchHinweis As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=10)> Public SuchNummer1 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf1 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf2 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf3 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf4 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf5 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf6 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf7 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf8 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf9 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf10 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf11 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf12 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf13 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf14 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf15 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf16 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchKopf17 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchDatei As String

        ' *******************************************************************************************************

    End Structure


    ' *******************************************************************************************************
    ' Such-Tabelle mit Feldlänge
    <StructLayout(LayoutKind.Sequential)> Public Structure WPFStandardSuchTabelle<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=101)> Public SuchWas As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=11)> Public SuchAufDatum As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2)> Public SuchFehlerKZ As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchBeschreibung As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchImage As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=27)> Public SuchMitarbeiter As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=11)> Public SuchErledigenBisDatum As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2)> Public SuchErledigtKZ As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=11)> Public SuchErledigtDatum As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public SuchWasGemacht As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText9 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText10 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText11 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText12 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText13 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText14 As String<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=31)> Public SuchText15 As String
    End Structure

Now the Call...

    Declare Function QSLISTECALL Lib "QSLISTE.dll" (ByRef VBSATZ1 As VBSATZ01, ByRef VBSATZ4 As VBSATZFREITEXTSUCHE) As Integer
           CblStatus = QSLISTECALL(VBSATZ001, VBSATZFreitextSuche)

Have anyone an idea without cutting fields?

Best Regards

Bernd

XPS to RTF or Word

$
0
0

hi Guys,

I'm evaluating a reporting engine, and the only formats it can export to are XPS, PDF, MS Excell. Is there a way to convert one of these formats to RTF or MS Word?

thanks,

fifty


fifty


Ribbon Window - Office 2013 style

$
0
0

Hi everybody,

I would like to create a WPF Ribbon application that looks like Office 2013 / Visual Studio 2013.
Can I do that with VS 2012 and the Framework 4.5 ?
Do I have to upgrave my IDE to VS 2013 ?
Is Office 2013 ribbon style natively supported by the framework ?

Thanks in advance for your help.



WPF Windowless App - Weird Icon

$
0
0

Hi all,

I have a windowless app, that is effectively a silent background app. It has no footprint in the tray. However I've recently noticed that it is in fact displaying a small, circular icon, that I've never seen before. Here it is, can anyone shed any light on how I can remove this? Or just what it is!

UFO!

Regards,

Jib

Programmatically add column and rows to grid and add the button control in each cell.

$
0
0

Hello

I am newer in WPF. I want to create the grid of M rows and n Columns. In each cell I want to add a button control and set its come of the properties. What is the easier code using either any of the LOOP  like For, Foreach etc. These all things I want to do programmatically in CS file and not through XAML.

Thanks for any reply in advance

Get value from from One Event to Another

$
0
0

I am having an issue and i am stumped. I am new to C# so please take it easy on me but also give it to me straight. The problem is, I have created a dynamic button that creates an instance of a textbox into the canvas. I want to take the textbox.text from the textbox and play the result. The var is called tts.Text. There is a routed event arg called read text below. How can i get that value to play in the read text arg?

         public void Add_Click(object sender, RoutedEventArgs e)
        {
            //creates a new tts area to write content.
            TextBox tts = new TextBox();
            tts.Name = "newTXT";
            tts.Padding = new Thickness(5.0);
            tts.Text = "Write your text here.";
            ttsArea.Children.Add(tts);

            //Creates a new stackpanel to host the play and stop buttons
            StackPanel txtContent = new StackPanel();
            txtContent.Orientation = Orientation.Horizontal;
            ttsArea.Children.Add(txtContent);

            //Creates the Play button
            Button read2 = new Button();
            read2.Name = "play2";
            read2.Content = "Play Audio";
            read2.Width = (86);
            txtContent.Children.Add(read2);
            read2.Click += new RoutedEventHandler(readText);


            //Creates the stop button
            Button stop2 = new Button();
            stop2.Name = "stopBtn2";
            stop2.Content = "Stop Audio";
            stop2.Width = (86);
            txtContent.Children.Add(stop2);
            stop2.Click += new RoutedEventHandler(stopReading);
}

         

         private void readText(object routed,RoutedEventArgs e) 
         {
             speech.Speak(inputText);
         }

         private void stopReading(object routed, RoutedEventArgs e) 
         {
             speech.SpeakAsyncCancelAll();
         
         }

       
    }

Getting Datagrids to do CRUD operations nicely with entity framework, in a mvvm manner

$
0
0

I have an application with a very usual setup: A set of views, each having a viewModel, which in turn works against entity framework (db first) which is my model. I'm trying to stay true to MVVM. The application is quite "thin", it's basically a more user friendly alternative for our users instead of using Microsoft SQL Management Studio. So there is a lot of connecting various form controls to database columns, opening windows corresponding to details of a master object etc.

So what I did was to change myModel.tt to generate ObservableCollections instead of hashsets and icollections, this lets me add and remove rows in datagrids in a very nice way without much boiler plate code since the bindings can work on properties which are basically just links to specific parts of the database, like so:

public ObservableCollection<SubstanceGroup> SubstanceGroups
        {
            get
            {
                return Substance.SubstanceGroups;
            }
            set
            {
                Substance.SubstanceGroups = value;
                OnPropertyChanged("SubstanceGroups");
            }
        }

However, if I edit a field in a datagrid, no binding will fire since EF entities do not implement INotifyPropertyChanged. The usual answer to other people with my problem is to not mix up the model with the viewModel, implying that you should create classes (for every entity) that implement INotifyPropertyChanged and then handle the communication between the local object and the entity explicitly. This seems enormously inefficient to me, "DRY" becomes just "RY".

Have I missed something obvious here? Should I change my generated entity classes? Any other suggestions?

Condition checking inside the MultiTrigger Actions?

$
0
0

Hi

I have on condition ,

which is to be "checked inside the MultiTrigger.EnterActions and MultiTrigger.ExitAction." * (Not inside the MultiTrigger.Condition) *

I searched for something like:-

 <MultiTrigger.EnterActions>

 <Condition Property="Tag" Value="Selected">

                    <BeginStoryboard>
                        <Storyboard>
                            <ThicknessAnimation Storyboard.TargetProperty="BorderThickness" From="0,0,0,0" To="0,1.5,0,1.5"  Duration="0:0:0.10"/>
                        </Storyboard>
                    </BeginStoryboard>
                </MultiTrigger.EnterActions>

</Condition>

 </MultiTrigger.EnterActions>

May i know is there any way to this?

Thanks in advance.


NANDAKUMAR.T

Strange Selector Issue in DataGrid

$
0
0

We have a DataGrid that contains a variety of template columns. What we're finding is that clicking on a cell in a different row from the currently selected row exhibits inconsistent behavior with respect to the selected row indicator. For example, if the cell contains a TextBox, the selected row indicator follows. However, if the cell contains a DoubleUpDown (from the "Extended WPF Toolkit"), the selected row indicator does not follow. I'd really like to have the selected row indicator follow the selection!  Any idea why this is happening and how I can fix it?

Thanks!

Brad.


Transfer data Between two Usercontrol inside of Mainwindows

$
0
0

Goal:
The input data that is located inside of the textbox search (usercontrol_menu.xaml) shall be transferred and then to be used inside of usercontrol_number1.xaml.

Problem:
I don't know what to do. What tactics and how to do it? From your experience, how should you do it?

Information:
- MainWindows.xaml is located in a separated project.

how do wizard next/previous button work?

$
0
0

Hi all,

I was wondering how to implement a next/previous button like the excel file import wizard. I thought a global variable with a number will hold the current state. Then a switch statement inside the button click event would call a function based on the state value. This sounds rather crude though. Is there a better way?

Thanks

Assign a unique instance names during instantiation.

$
0
0
I have a for loop that instantiates a textbox x number of times. It works perfectly, but now i need to assign names to each textbox. I want to be able to assign a name or number or some type of identifier so i can later target a specific instance.
         public void Add_Click(object sender, RoutedEventArgs e)
        {
            //creates a new tts area to write content.
             fields = Convert.ToInt32(numberOfFields.Text);
             for (int i = 0; i < fields; i++)
             {
                 speech = new SpeechSynthesizer();
                 tts = new TextBox();
                 tts.Name = "newTXT";
                 tts.Padding = new Thickness(5.0);
                 txtText.Text = tts.Text;
                 ttsArea.Children.Add(tts);
                 //Creates a new stackpanel to host the play and stop buttons
                 StackPanel txtContent = new StackPanel();
                 txtContent.Orientation = Orientation.Horizontal;

                 ttsArea.Children.Add(txtContent);

                 //Creates the Play button
                 Button read2 = new Button();

                 read2.Name = "play2";
                 read2.Content = "Play Audio";
                 read2.Width = (86);
                 txtContent.Children.Add(read2);
                 read2.Click += new RoutedEventHandler(readText);

                 //Creates the stop button
                 Button stop2 = new Button();
                 stop2.Name = "stopBtn2";
                 stop2.Content = "Stop Audio";
                 stop2.Width = (86);
                 txtContent.Children.Add(stop2);
                 stop2.Click += new RoutedEventHandler(stopReading);
             }

cast objects from observablecollection and filter by criteria into DataGrid

$
0
0

I have a c# custom ObservableCollection, MyObservableCollection : ObservableCollection<MyClass>, that I am displaying in several different WPF windows.  I would like to display information about this collection, specifically members of MyInheritedClass : MyBaseClass in another window that meet certain criteria, say MyInheritedClass.PropertyA == true.  In particular, I want to display this filtered set in a WPF DataGrid.  I want to use the same MyObservableCollection as I use in the other windows so I only have to maintain one copy of the collection and have it automatically synced between the windows.  Note I don't have any experience with CollectionViews so if your answer involves this, please be specific so that I can understand it in this compound case.

To be more specific my shell classes are:

public class MyClass : INotifyPropertyChanged
{
     public MyClass() {}
     public event PropertyChangedEventHandler PropertyChanged;
}

public class MyInheritedClass : MyClass
{
     public MyInheritedClass() {}
     public bool PropertyA
     {
        get { return _PropertyA; }
        set
        {
            _PropertyA = value;
            if (PropertyChanged != null)
               PropertyChanged(this, new PropertChangedEventArgs("PropertyA"));
        }
     }
     private bool _PropertyA;
}

public class MyObservableCollection : ObservableCollection<MyClass>
{
     public MyObservableCollection() {}
}

public partial class MyWindow : Window
{
     public MyWindow(MyObservableCollection c)
     {
        InitializeComponent();
        myDataGrid.ItemsSource = c;
     }
}

Again, I want to display in the DataGrid in MyWindow only objects with PropertyA == true.  PropertyA is only a property of the inherited class.

Thanks!

Is it possible to have a Context Menu in all the nodes (leaf and non-leaf) of a Tree+GridView combination?

$
0
0

Is it possible to have a Context Menu in all the nodes (leaf and non-leaf) of a Tree+GridView combination?

My application is currently implemented by a GridView inside a TreeList.

GridView in a TreeList

If possible, I would like to be able to right-click in a set of Shift-Clicked or Option-Clicked rows.

TIA



Viewing all 18858 articles
Browse latest View live


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