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

windows 8 store app- authorize exception

$
0
0

Hellow

i am tring to write simple json file localy

in my windows 8 store app

but i get an exception : UnauthorizedAccessException

this is the code:

 internal async static void Save(List<RecipeDataGroup> list)
        {

            string json = JsonConvert.SerializeObject(list);

             var _file = await Package.Current.InstalledLocation.CreateFileAsync("Data\\Recipes2.txt");

            await Windows.Storage.FileIO.WriteTextAsync(_file ,json );



        }
How to solve it ?

m.sh


how to disable button glow when clicked

$
0
0
Is there a way to disable the like pulsating blue glow when a button is clicked in wpf?This is the effect I'm talking about btw.

Unexpected native crash in WPF 4.5 .Net application

$
0
0
Hello Everybody,

                              We have a unexpected, unpredictible crash that happens on our application only in rare circonstances; Especially on virtual servers in a Citrix environment but we also had the crash on different 64 bits Windows 7 computers.

                              THe crash is a native Windows low level crash, it is not a .net exception there it can't be caught in a try cath nor produces us an usable stracktrace we could investigate.

                              It is extremly complex to reproduce the bug, therefore trying to catch and debug the process win Visual in C++ Native mode is impossible.

The error message in french unfortunately, attached to this post states :
APPCRASH

IN the module StackHash_3e4b

Our Google investigations pinpointed a potential crash at loading a bad 32 bits dll in a 64 bits environment. But we have no clues. The app works fine on hundred of computers/citrix servers in the différents hospitals throughout france that use it.

The two native dependencies we think that could be guilty are :

1) WPF -> If the failure comes from a bad driver for instance (
2) Native Oracle dlls we are using for our datalayer and that we attack with the ORM Devart

VB.NET WPF : Can not read the listbox item in another form

$
0
0

hi i have a problem in the listbox item in a different form.

I put the item listbox on the form w_list, I load the listbox item from notepad.
the problem is an error in the form p_list, where the label that I used to read the value of the items in the form w_list an error:

Object reference not set to an instance of an object

line error : line label.Content = w_list.ListBox1.SelectedItem.ToString


 

GDI+ DrawPath issue for Halo Text

$
0
0
Hi There,
All I wanted to do is to create a Text with halo around it. Everything works fine for me except the letter "M". I see spikes when I rendering M. Below is the code I used to generate a png file with the text. If you check the output image "outputtext.png", the letters A R and Y all look good but M.

The issue I noticed is with the size of the Pen used for DrawPath. When I set the pen width to 1.0, I don't see the spikes.

g.DrawPath(new Pen(Color.White, 6.0F), path);


Any help is appreciated.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace AllTimeConsolTest
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Drawing.Image img = new System.Drawing.Bitmap(200, 100);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);

            g.PageUnit = System.Drawing.GraphicsUnit.Pixel;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.Clear(Color.Black);

            string text = "M A R Y M ";

            System.Drawing.PointF LabelPoint = new PointF(10, 30);
            //System.Drawing.SizeF fontSize = g.MeasureString(text, label.Font); //Calculate the size of the text

            Font f = new Font("Arial", 26, FontStyle.Bold, GraphicsUnit.Pixel);
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddString(text, f.FontFamily, (int)f.Style, f.Size, LabelPoint, System.Drawing.StringFormat.GenericTypographic);

            g.DrawPath(new Pen(Color.White, 6.0F), path);
            g.FillPath(new System.Drawing.SolidBrush(Color.Black), path);

            img.Save("OutputText.png", System.Drawing.Imaging.ImageFormat.Png);
            img.Dispose();
        }

    }
}

Thanks in advance.

Copy/paste full row, full column, a cell on datagrid using MVVM?

$
0
0

What is the best way to implement on datagrid? As I am new on this, I had some researches but I am confused because there are some complicated implementations and easy ones? I try to understand the best way.

Adding simply selection mode and selection Unit doesnt help. Because it only copies the row but I cant paste it simply as a new row.

 SelectionMode="Extended" SelectionUnit="FullRow"  >

this approach in the article looks old to me. Not sure if there is anything new and much easier with newest framework. I am using MVVM light in my project.Attached is the sample project similar to my original project. can you please recommend me the best way for the following?

- Full Row(s) copy-paste

-1 or multiple columns copy-paste (optional)

- cell copy-paste


"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."

writer XML doesn't right

$
0
0

I want to save data in a XML file.

In C# I have 

SortedList<int, string> highes = new SortedList<int, string>();

public void Save() { XmlWriter writer; writer = XmlWriter.Create(Path.GetDirectoryName(Path.GetDirectoryName(Application.StartupPath)) + "\\highS" + Level.ToString() + ".xml"); for (int i = highes.Count - 1; i >= 0; i--) { writer.WriteStartElement("point"); writer.WriteAttributeString("point", highes.Keys[i].ToString()); writer.WriteStartElement("player"); writer.WriteAttributeString("player", highes.Values[i]); writer.WriteEndElement(); } writer.Close(); }  

When I write the same function in WPF, it doesn't change the XML file. there for, it shows the new data, but when updating the window it shows the XML without the new data. means, it doesn't add/change the xml!!!

What should I do ?

Any third party mediaelement ?

$
0
0

Hi,

is there any third party media element for wpf which support wide range of formats including uncompressed formats.

media element - default

mediaurielement - wpf media kit

Visioforge - excluding this tool

                  

is there any other media players for wpf.

Please list and help me


Setting Clickonce Installer Language based on Language Settings

$
0
0

Clickonce installer always displays in English language. 

In my scenario, I need to display installer in German, Italy, French and English as my WPF application handles

Multilingual texts based on System Display Language.

Please suggest how to create Clickonce installer based on System Display Language Settings.

How to generate WPF Xaml through XSD (xml schema definition)

$
0
0

Hi Experts

I am working on Projects where we need to generate wpf ui (xaml) at runtime as per different requirements. We are trying to generate xaml from xsd file. We are able to generate UI from xml but as size of xml can be large we are reluctant to use xml as xaml generation source. I am attaching a sample image what we are trying to do

UI elements Description

For each complex node in xsd, we need a panel which can have add or delete button depending on minoccurs and maxoccurs of the node. Inside panel we want to add different ui elements.

Please suggest if there is any way to do this or any one have worked in this direction?

Thanks

Praveen

MouseHover

$
0
0

I'm transleting a project from C# to WPF

In C#, I have a function MouseHover for a label :

private void label_MouseHover(object sender, EventArgs e)
        {
            if (label.Text != "")
            {
                   label.BackColor = Color.Yellow ;
            }
        }


 How should I do in WPF ?       

[WPF] Combobox and dynamic bind

$
0
0
Hi,
in my application WPF, I'm using combobox and I bind the ItemsSource with a collection read from database, I would:
- capitalize the item, how is the better way?
- how to set the width of combobox as the length of the items?

Thanks.

PresentationHost.exe (XBAP) throw error: C Run-Time Error R6034

$
0
0

Hello,

we are hosting one of our WPF (.NET 3.5 SP1) components within XBAP and thus it delivered through browser (explorer 8.0) to client.
Some time clients (running explorer) receive error and this error thrown by presentetionhost.exe. The error is: C Run-Time Error R6034.
We looked the error in forums and it appears related to manifest. But manifest exists for that WPF/XBAP application. Furthermore, the error does not occurs always only sometime and it not consistent it cannot be recreated on same machine for same scenario.
Cleaning online app cache with mage.exe -cc does not resolve issue it continue to appear occasionally.

Some comment:
1. Sometime application continues working after error box closed, but sometime it crushes.
2. May be it is not relevant but, the application accessing server side with WCF, but no error in this area.
3. I read another thread of this forum: Deploying WPF app - runtime error R6034 (social.msdn.microsoft.com/Forums/?en-US/wpf/thread/233fee41-6cf9-40cd?-bf39-66ddade11746)
 and there the sxstrace tool in use, which in my case is not possible due XP OS.

Does someone have ideas how to get rid of the error?

Thanks, Pavel

Is it possible to bind the first element in a collection in a datagrid?

$
0
0

I have a datagrid and I need to bind a property in the first element of the collection of my datasource object. By the momento I am using a converter:

<DataGridTextColumn Header="MyValue" Binding="{Binding Converter={StaticResource myConverter}}"/>

But I would like to avoid the need to use a converter, so I have tried this:

<DataGridTextColumn Header="MyValue" Binding="{Binding MyCollectionProperty.ElementAt(0).MyValue}"/>

Is there any way to do it?

Using RawPrinterHelper - How to send the printed paper to default Output Bin/Tray.

$
0
0

As a reference I have used the source from https://support.microsoft.com/kb/322091/en-us?wa=wsignin1.0 for  RawPrinterHelper. This is working great.

Now the problem I am having is, I have two computers and one printer with two printer output Trays or Bins. I configured  Printer Settings in both the computers, so that first computer prints papers to tray1 and second computer prints papers to tray2. These are working as expected when I print local documents. but when I use RawPrinterHelper, all the papers going to tray1. How to handle this issue?

Thank you.


Buttons with background images

$
0
0

Hi,

I have a quit button that is transparent background and uses a background image (plus no borders/hover effects).

<Button x:Name="btnQuit" Click="btnQuit_Click" Margin="781,15,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="16" Width="16"><Button.Template><ControlTemplate TargetType="{x:Type Button}"><Border x:Name="outerBorder" Background="Transparent" BorderThickness="0" Width="16" Height="16"><Border.Style><Style TargetType="{x:Type Border}"><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="BorderBrush" Value="#CED58F"/></Trigger></Style.Triggers></Style></Border.Style><Border BorderThickness="0"><Border.Style><Style TargetType="{x:Type Border}"><Style.Triggers><DataTrigger Binding="{Binding IsMouseOver, ElementName=outerBorder}" Value="True"><Setter Property="BorderBrush" Value="#9EB01C"/></DataTrigger></Style.Triggers></Style></Border.Style><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions><Image Width="16" Height="16" Grid.Column="0" Source="Resources/_Shared/btnQuit.png" Stretch="Fill" Margin="0 0 0 0"/><TextBlock VerticalAlignment="Center" Grid.Column="1" FontSize="22" FontWeight="Bold" Foreground="#9EB11C" Margin="12 -2 0 0" Opacity="0.9"><Run Text="PURCHASE"/></TextBlock></Grid></Border></Border></ControlTemplate></Button.Template></Button>

Could someone advise on the following:

- How best would I adjust the background position of the background image?

- How would I adjust the opacity (from 75% to 100%) on hover over?

- Is this the most efficient way of doing this?

Thanks

Highlight only Searched keywords in a Datagrid

$
0
0

Hi

I have a datagird and a searchfunction wich shows only datagridrows containthe searched Keyword.

Now i would like to highlight the Searched Keyword in the datagird, i can get acces to the row or cell contains the keyword and also highlight them(for example like this: http://blogs.microsoft.co.il/blogs/tomershamam/archive/2009/08/27/wpf-datagrid-search-and-highlight.aspx ).

But how can i highlight only the keyword like google or opera-browser etc.?

Thanks very much.




WPF Application crashing on startup on some computers but not all.

$
0
0

I have a .NET WPF application targeting the .NET 4 framework (previous versions of the same application targeted 3.5).  I'm not sure if the change in the framework targeting is related to this problem but I figured I'd point it out.


I am getting a crash when the application starts up, but only on some PC's.  On other PC's it works fine.  On any of these PC's previous versions of this same application worked fine.  The crash is due to an unhandled exception on the app startup.

 

Here is the stack trace of the exception:

Application: MyApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
   at System.Signature.GetSignature(System.SignatureStruct ByRef, Void*, Int32, System.RuntimeFieldHandleInternal, System.IRuntimeMethodInfo, System.RuntimeType)
   at System.Reflection.RuntimePropertyInfo.get_Signature()
   at System.Reflection.RuntimePropertyInfo.get_PropertyType()
   at System.Reflection.CustomAttributeData..ctor(System.Reflection.RuntimeModule, System.Reflection.CustomAttributeRecord)
   at System.Reflection.CustomAttributeData.GetCustomAttributes(System.Reflection.RuntimeModule, Int32)
   at System.Reflection.CustomAttributeData.GetCustomAttributesInternal(System.Reflection.RuntimeAssembly)
   at System.Reflection.RuntimeAssembly.GetCustomAttributesData()
   at System.Reflection.CustomAttributeData.GetCustomAttributes(System.Reflection.Assembly)
   at System.Resources.ManifestBasedResourceGroveler.GetNeutralResourcesLanguage(System.Reflection.Assembly, System.Resources.UltimateResourceFallbackLocation ByRef)
   at System.Resources.ResourceManager.CommonSatelliteAssemblyInit()
   at System.Resources.ResourceManager..ctor(System.String, System.Reflection.Assembly)
   at System.Windows.SplashScreen..ctor(System.Reflection.Assembly, System.String)
   at MyApp.App.Main()

--------

In addition to the exception above, which my app logs to event viewer, I also have another event that occurs at the same time, also in the application log.  The source is "Application Error" and it reads as follows:

 

Faulting application name: MyApp.exe, version: 2.4.1.0, time stamp: 0x4d278ccc
Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdbdf
Exception code: 0xe0434352
Fault offset: 0x0000b727
Faulting process id: 0xe28
Faulting application start time: 0x01cbaec139ccd566
Faulting application path: C:\Program Files (x86)\My App Path\My App\MyApp.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 77e811de-1ab4-11e0-a6cf-a4badbfae9cd

 

--------------------------

 

So while it appears that this is happening on the splash screen constructor, I am very confused because at this point I have removed the splash screen entirely from the app.  There is no splash screen configured.  And it's a FileNotFound exception, I don't know what file it's looking for.

 

Any help would be much appreciated.

 

Thanks,

Greg

 

MVVM Light and View in ShowDialog

$
0
0

I wrote an MVVM Light application and Entity Framework written that some characters in a TextBox, after pressing enter opens a second window that displays all names that have the same initials:

MainViewModel:

namespace DataGridSearch_MvvmLight.ViewModel
{
    /// <summary>
    /// This class contains properties that the main View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {
        private string _name = string.Empty;
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                Set(() => Name, ref _name, value);
            }
        }
        public RelayCommand SearchCommand { get; private set; }
        public RelayCommand<EventArgs> KeyDown_ParseCommand { get; private set; }

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            SearchCommand = new RelayCommand(() => Search());

            KeyDown_ParseCommand = new RelayCommand<EventArgs>(onKeyDown);
        }

        private void onKeyDown(EventArgs e)
        {
            var pressedKey = (e != null) ? (KeyEventArgs)e : null;

            if (pressedKey.Key == Key.Enter || pressedKey.Key == Key.Tab && pressedKey != null)
            {
                Search();
            }
        }

        private void Search()
        {
            using (var ctx = new MyContext())
            {
                ctx.Configuration.LazyLoadingEnabled = false;

                List<Customer> query = ctx.Customers
                     .Where(x => x.Name.StartsWith(Name))
                     .OrderBy(x => x.Name)
                     .ToList();

                Messenger.Default.Send<NotificationMessage>(new NotificationMessage("Open Window"));

                Messenger.Default.Send<List<Customer>>(query, "BindCustomerList");
            }
        }
    }
}

MainWindow - Code Behind:

namespace DataGridSearch_MvvmLight
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Closing += (s, e) => ViewModelLocator.Cleanup();
            Messenger.Default.Register<NotificationMessage>(
                this,
                msg =>
                {
                    if (msg.Notification == "Open Window")
                    {
                        var win = new ViewDataGrid();
                        win.ShowDialog();
                    }
                });
        }
    }
}

ViewDataGrid:

namespace DataGridSearch_MvvmLight.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class DataGridViewModel : ViewModelBase
    {
        Customer _SelectedItem;
        public Customer SelectedItem
        {
            get
            {
                return _SelectedItem;
            }
            set
            {
                Set(() => SelectedItem, ref _SelectedItem, value);
            }
        }

        ObservableCollection<Customer> _Customer;
        public ObservableCollection<Customer> Customer
        {
            get
            {
                return _Customer;
            }
            set
            {
                Set(() => Customer, ref _Customer, value);
            }
        }

        public RelayCommand<EventArgs> MouseDoubleClick_ParseCommand { get; private set; }

        /// <summary>
        /// Initializes a new instance of the DataGridViewModel class.
        /// </summary>
        public DataGridViewModel()
        {
            Customer = new ObservableCollection<Customer>();

            MouseDoubleClick_ParseCommand = new RelayCommand<EventArgs>(onMouseDoubleClick);

            Messenger.Default.Register<List<Customer>>(this, "BindCustomerList", collection =>
                {
                    foreach (var item in collection)
                    {
                        Customer.Add(item);
                    }
                });
        }
        private void onMouseDoubleClick(EventArgs e)
        {
            var pressedKey = (e != null) ? (MouseButtonEventArgs)e : null;

            if (pressedKey.LeftButton == MouseButtonState.Pressed && SelectedItem != null)
            {
                //Name = SelectedItem.Name;
            }
        }
    }
}

My problem is as follows. In the Code Behind of the MainView if I write:

win.ShowDialog();

The list is never passed on the first try, but from the second onwards. Otherwise if I write:

win.Show();

Everything is working properly. But I need the second View opens in the ShowDialog().

I think the problem is caused by the use of two Messenger:

Messenger.Default.Send<NotificationMessage>(new NotificationMessage("Open Window"));
Messenger.Default.Send<List<Customer>>(query, "BindCustomerList");


Search in a DataGrid/ListView and highlight text...

$
0
0

Hi All,

In my application, i have a ObservableCollection which i am binding to a DataGrid or ListView. I have a textbox which will accept the user inputs and this text needs to be searched in the DataGrid or ListView cells. The found text (and not complete cell text) from the cell should be highlighted with different background.

How i can do this?

Thanks in advance,

IamHuM

Viewing all 18858 articles
Browse latest View live


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