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

SQL Server CE

$
0
0
Hello everybody, I'm starting to develop an application that uses SQL Server CE, does anyone know where I can find study material, because I need to do it all via code WPF / VB? I not found much on the internet. Thank you.

MediaElement Position issue:

$
0
0

There are similar issue related to MediaElement.Position property like the on the following thread:

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ebbbca48-1b19-425a-a757-c9108bb6de02/

But my problem is a bit different.

ScrubbingEnabled is true and I've a slider which can be used to seek video. now whenever I seek the near the end of the video or sometimes to the end, MediaElement dose not respond, like it's hanged without any error event, it dose not even update event if I set it's Position again to starting or somewhere in between, Also in this condition when I play the video again, it seam like it's updating the value of position, but not playing the video. [I am checking the value of Position on timer.]

Only solution left is to load another file.

Thanks in advance...

Enable mouse wheel scroll for popup control

$
0
0
How do I enable mouse wheel scroll (vertical) for a pop up control in WPF?

creating a ViewModel class

$
0
0
  

I would like to create a ViewModel Class to retrieve the values from the Database. 
My goal is to retrieve the Values of Usage of RAM (Ram total & Ram available) from my DB Table and then display it on my View.

This is what I have done so far on my ViewModel Class


public class RamViewModel : INotifyPropertyChanged    
{       
float _ramTotal;  
float _ramUsed;  

public float RamTotal    
{   get { return _ramTotal; }   
{  set { _ramTotal = value; RaisePropertyChanged("RamTotal"); }  }       

public float RamUsed 
{  get { return _ramUsed; } 
{  set { _ramUsed = value; RaisePropertyChanged("RamUsed"); }      
}

private void RaisePropertyChanged(string p)    
{ throw new NotImplementedException(); } 

}
    



when I build the class, I got this error stating, " ViewModel.RamViewModel Does not implement interface member 'System.ComponentModel.INotifyPropertyChanged.PropertyChanged'"

Am I missing some collection here ?

kindly help to proceed further


Thanks


How to get BindingExpression in InputBinding CommandProperty

$
0
0
How do you get BindingExpression from the  InputBinding CommandProperty? InputBinding is not a framework element so it does not have the GetBindingExpression method. So how do you get it?

how to avoid item selection from extra blank space header in listview ?

$
0
0

Hi all,

I am using wpf Listview control in my c#. in this i am using GridViewColumn headers and taking some listview items.

when i am selecting the listview items it also selects the extra black space of list view item as shown in below image.

if i will select any listview item. my selection should appear till my last header (Age), as shown in red box in above image.

thanks in Advance :)


sumitk

Exception when printing XPS-Document

$
0
0

Hallo,

with our application document will be printed via the XpsDocumentWriter.

Almost everytime the print works without any problems.

But from time to time the following error occurs:

PrintTicket provider failed to convert DEVMODE to PrintTicket.Win32 error:-2147467259
   at MS.Internal.Printing.Configuration.PTProvider.ConvertDevModeToPrintTicket(Byte[] devMode,PrintTicketScope scope)
   at System.Printing.Interop.PrintTicketConverter.InternalConvertDevModeToPrintTicket(PTProviderBase provider,Byte[] devMode,PrintTicketScope scope)
   at System.Printing.PrintTicketManager.ConvertDevModeToPrintTicket(Byte[] devMode)
   at System.Printing.PrintQueue.get_UserPrintTicket()
   at System.Windows.Xps.Serialization.NgcPrintTicketManager.ConstructPrintTicketTree(XpsSerializationPrintTicketRequiredEventArgs args)
   at System.Windows.Xps.Serialization.NgcSerializationManagerAsync.OnNGCSerializationPrintTicketRequired(Object operationState)
   at System.Windows.Xps.Serialization.NgcSerializationManagerAsync.SaveAsXaml(Object serializedObject)
   at System.Windows.Xps.XpsDocumentWriter.WriteAsync(DocumentPaginator documentPaginator,PrintTicket printTicket)
   at Willis.Base.Pdf.PagePrintMailControl.simpleButtonPrint_Click(Object sender,EventArgs e)

What could be the reason for this?

Printing one document on day a on the same printer by the same user can result in the error but on day b the same document on the same printer by the same user can be printed without an error, what is pretty strange.

Thanks for your help.

Calling EXE method from DLL

$
0
0
Please help me solve my problems by giving me some ideas or sample codes on how to call a method inside a WPF application (EXE) from a DLL (UserControl Library).

I have two WPF projects:
(1) MainProgram - WPF Application
(2) ViewsLibrary - WPF UserControl Library

Basically, the ViewsLibrary contains UserControls (e.g ViewA) which will be displayed in MainProgram as an MDI child.
The MainProgram receives message from the server, "Data Settings",  for the controls defined in ViewA.
In order for the ViewA to get/receive the Data Settings from MainProgram, ViewsLibrary needs to call a method inside the MainProgram (e.g MainProgram.SendDataSettings).
The controls in ViewA will be set upon receiving the Data Settings (ON / OFF / Alarm / Etc)..

Assembly 'Reuxables Legacy' is not referenced by this project

$
0
0

I have been using a free resource dictionary which I found on the internet since starting to use WPF on VS2010. Since upgrading to VS2012 I have been getting the above warning for each form when I open it. Despite this, I am convinced that the resource dictionary is still in use as I can see its visual impact. Has anyone got an explanation for this (admittedly minor) problem? Here is a screen print illustrating what happens:

WPf - XBAP application screen resolution issues

$
0
0

Hi All,

Our XBAP application needs to be running on our user laptops/desktops these laptop/desktops are having different screen resolutions. Due to this our appreciation appearing in laptop/desktops chopped or on some laptop/desktops layout/controls appear differently.

As some posts suggested we used ViewBox (with stretch property UniformToFill or Uniform ) with ScrollViewer , this introduced a problem of controls, labels appearing bigger  occupying the max screen which is also not a very good solution..

<Grid>
            <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
                <Viewbox Stretch="Uniform">

....

...

</Viewbox>
          </ScrollViewer>
 </Grid>

Appreciate if someone can help with a solution which solves our issue.

Prakash.G

Your browser's cookie functionality is turned off. Please turn it on.

$
0
0
i am tring to get login to gmail by posting data...
            

            HttpWebRequest hi = (HttpWebRequest)HttpWebRequest.Create("https://www.google.com/accounts/ServiceLoginAuth?service=mail");
            
            Cookie myCookie = new Cookie(HttpRequestHeader.CacheControl.ToString(), "no-cache=set-cookie");
            CookieCollection a = new CookieCollection();
            a.Add(myCookie);
            hi.Method = "POST";
                
            
            hi.CookieContainer = new CookieContainer();
 
            string PostData = "continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Ftab%3Dwm&service=mail&rm=false&dsh=-28214021908461826&ltmpl=default&scc=1&GALX=6-CDla8snug&pstMsg=1&dnConn=&checkConnection=youtube%3A1271%3A1&checkedDomains=youtube&timeStmp=&secTok=&Email=youremail&Passwd=password&signIn=Sign+in&rmShown=1";
            
            hi.ContentType = "application/x-www-form-urlencoded";
            byte[] post = UnicodeEncoding.UTF8.GetBytes(PostData);
            Stream stream = await hi.GetRequestStreamAsync();
            stream.Write(post, 0, PostData.Length);
            

            WebResponse response = await hi.GetResponseAsync();
            response.GetResponseStream();
          
            string pageSource;   
            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                pageSource = sr.ReadToEnd();
            }
            b.NavigateToString(pageSource);
           
           
            
            b.NavigateToString(pageSource);
            t.Text = pageSource;
            
when i run this i get an error "Your browser's cookie functionality is turned off. Please turn it on."

          

DataAnnotations in Interfaces for WPF Validation

$
0
0

I'm building a code first object model and would like to describe some of my classes properties in interfaces.

A good example is an ISearchStorehause interface, where classes implementing this are forced to have id and a name added to their signature.

    public interface ISearchStorehause
    {
        [Range(1, 999999, ErrorMessageResourceType = typeof(Resource_ua_UA), ErrorMessageResourceName = "Storehause_Id_ErrorMessage")]
        int Id { get; set; }

        string Name { get; set; }
    }

And I have class implemented this interface.

    [MetadataType(typeof(ISearchStorehause))]
    public class Search : ValidationModel, ISearchStorehause
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

Class ValidationModel implement IDataErrorInfo interface.

When I do it for access to DB though Entity Framework 5, all work correctly. When I do it for WPF, restriction for id field placed on these interface properties are ignored... so I should move it to the class.

Why I can't describe any restrictions for WPF in the interface?

Accessing DataContext in WPF

$
0
0
Hi
 
I have window that contain a frame which is binded to a viewmodel , a login page is assigned to the frame, I want to be able to access a property in the window datacontext from the page. Any ideas what to do ?

Getting button as return type from function

$
0
0

I have function which search a particular name button in grid by name and return button.

 public Button search_Button(TextBlock position, Grid grim)
        {
           try
            {
                var temp =position.Text;            //getting position of button
                object item = grim.FindName(temp);
                Button tbtn = (Button)item;
                return tbtn;      // return button
            }
            catch (NullReferenceException ex)
            {
            }
        }

but it is not compiling giving error "not all code path return a value. What is wrong with my function?

How to get a Single click on Image in wpf.

$
0
0

 Hi,

   I am working on c # application while using WPF. I am using image control in xaml which is integrated in xaml style.On that image I want a  single click  but I am not getting any click on it.Please let me suggest how I will get click on that image .

Thanks

Swati


How do I call IScrollInfo.MakeVisible(visual,rect) to scroll somethign into view?

$
0
0

checked google, ms-help,
IScrollInfo.MakeVisible should do exactly what I want (according to description), it just doesn't seem to work

<ScollViewer Height=20>
  <StackPanel x:Name="newHell"
                      ScrollViewer.CanContentScroll="True"
                      ScrollViewer.VerticalScrollBarVisibility="Visible">
    <TextBlock Text="1" x:Name="tb1"/>
    <TextBlock Text="2" x:Name="tb2"/>
    <TextBlock Text="3" x:Name="tb3"/>
    <TextBlock Text="4" x:Name="tb4"/>
    <TextBlock Text="5" x:Name="tb5"/>
  </StackPanel>
</ScrollViewer>

..
some Button click closer to hell
{
  var s = (IScrollInfo)newHell;
  s.MakeVisible(tb3, ???);  <- want to make tb3 visible, HOW? what parameter value is requested to make this simple line of code work?
}


If you don't dig, you won't find it


Consecutive navigate to the same page, WPF Browser in a frame

$
0
0

Hi,

I can’t navigate second time to the same page!

The first Navigate it is OK! For example „catode“  to "Views/Page2.xaml" 

        

The second  mMenu_Click  “anode”  also to  "Views/Page2.xaml" doesen’t  rich the Loaded

this.Loaded +=newRoutedEventHandler(CancelNavigationPage_Loaded);

but is landing in :

void NavigationService_Navigating(object sender, NavigatingCancelEventArgs e)

{

}

Page1.xaml

 <Frame Grid.Row="2" Grid.Column="1" Name="frame1"/>

Page1.xaml.cs

privatevoid mMenu_Click(object sender,RoutedEventArgs e)

       {

          

           MenuItem mnu = (MenuItem)e.OriginalSource;

 

           GesLib.gloVar.Set_tableName(mnu.Name.TrimEnd());

           switch (mnu.Name)

           {

               case"anode":

                 frame1.NavigationService.Navigate(new System.Uri("Views/Page2.xaml",          UriKind.Relative));

                   break;

               case"catode":

                 frame1.NavigationService.Navigate(new System.Uri("Views/Page2.xaml",          UriKind.Relative));

                   break;

           }

       }

 

Repeater control in WPF/Winforms

$
0
0

Hi, 

I'm looking to write a simple forms application (Win Forms or WPF) that will need to display records in some form of grid on the screen. 

There would be a maximum of five rows and perhaps five columns on each, so no much to display really.  Ideally I would like to display the data in 

textboxes and allow it to be editable. 

I looked at DataGridView in Winforms but it does not look too good when there is not a full compliment of rows. 

I'm more used to ASP.Net and if this was a page I would use a repeater and add controls at runtime. 

So, questions... Whats would be best Win forms or WPF and what would the best repeating control be to use that I could add 

text boxes, button & possibly a checkbox? 

It will be a .net4 C# project

What am I missing here ?

$
0
0

Hi Experts,

This is what im trying to do.

I have created a user control with DataGrid coltrol which implements INotifyPropertyChanged. Added a Textblock to display the title of the grid. text property of the Textblock is binded to a CLR title property within the same control.

I have added this unse control to another XAML view and binded a list of items and the grid populates it correctly. Also i'm setting the title of the control within the calling xaml window but I dont see the title.

User Control's Title property 

        private string title;
        /// <summary>
        /// Get and Set the Title of the Control
        /// </summary>
        public string Title
        {
            get
            {
                return title;
            }
            set
            {
                title = value;
                PropertyValueChanged("Title");
            }
        }

How the list is generated for binding

public class StaffInformation
    {
        public enum Genders
        {
            Unknown,
            Male,
            Female,
        }

        [HeaderName("First Name"), ColumnIndex("0")]
        public string FirstName { get; set; }

        [HeaderName("Last Name"), ColumnIndex("2")]
        public string LastName { get; set; }

        [HeaderName("Email Address"), ColumnIndex("3")]
        public string Email { get; set; }

        //[HeaderName("Gender"), ColumnIndex("1")]
        //public Genders Gender { get; set; }

        [HeaderName("City"), ColumnIndex("4")]
        public string City { get; set; }

        [HeaderName("Profession"), ColumnIndex("5")]
        public string Profession { get; set; }

    }

    public class BindingCollection
    {
        public List<StaffInformation> StaffDetails
        {
            get
            {
                List<StaffInformation> staffInfo = new List<StaffInformation>();
                staffInfo.Add(new StaffInformation { City = "Colombo", Email = "kur@gmail.com", FirstName = "Kuru", LastName = "Thiya", Profession = "Eng" });

                return staffInfo;
            }
        }

        public string Title
        {
            get
            {
                return "Staff Details";
            }
        }
    }

How the DataContext is set to user control from calling xaml view's code behind

private void PopulateDataGrid() { BindingCollection bc = new BindingCollection();

//Setting the datacontext of user control StaffDetailsGrid.DataContext = bc.StaffDetails; StaffDetailsGrid.Title = bc.Title; }



How to Override a DependencyProperty?

$
0
0

Hello msdn, 

         How can I override a DependencyProperty, in such a way that,it do not hit the base class's PropertyChanged Callback methods?

Recently I have created a class with a dependency property, I have overrided this dependencyProperty in a descendent class, But when I change the value, It is hitting not only the derived class PropertyChanged callback, But also the base class, How can I avoid it hitting the base class?

Could anyone help me to do this, My code is given below.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication7
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            C c = new C();
            c.HasVlidation = true;
        }
    }
 public class P:Control
    {

        static P()
        {
            HasVlidationProperty =
            DependencyProperty.Register("HasVlidation", typeof(bool), typeof(P), new FrameworkPropertyMetadata(false,changed));
        }
        public static readonly DependencyProperty HasVlidationProperty;
        public bool HasVlidation
        {
            get { return (bool)GetValue(HasVlidationProperty); }
            set { SetValue(HasVlidationProperty, value); }
        }

        // Using a DependencyProperty as the backing store for HasVlidation.  This enables animation, styling, binding, etc...
        

        private static void changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            
        }

        
        public P()
        {
        }
    }

    public class C:P
    {
        static C()
        {
            P.HasVlidationProperty.OverrideMetadata(typeof(C), new FrameworkPropertyMetadata(false, changed));
        }

        private static void changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
           
        }
        public C()
        {

        }
    }


}

Regards

Salam

 


salampv.07

Viewing all 18858 articles
Browse latest View live


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