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

Button click validate Textboxes

$
0
0

Hi Guys, need you ideas. It may be simple but i need your help.

I got 3 text boxes, the first 2 to enter some texts & the third to get the selected value(image) from browse dialog image.

I got a button, when i click on the button I want to validate the user must have entered a value in any one of the first 2 text-boxes and in the third text box value is must.

I tried doing it with ìf`loop but something is not clear. Please give me some idea & i'll do it. Thank you.

private void visuCtemplateImage_Click(object sender, RoutedEventArgs e)
{

if(thtmlline1.Text.Length <= 0 || thtmlline2.Text.Length <= 0 && timageName.Text.Length <= 0) { MessageBox.Show("Enter any one of the text box & one image value in third text box"); return; }

}

Thank you.




WPF Datagrid with header locked

$
0
0

Hi to all,

I have a Datagrid with ItemSource pointing a set of machine object :

<DataGrid AutogenerateColumns="False" ItemSource={Binding SelectedEntity.Machines} /><DataGrid.Columns><DataGridTextColumn Binding="{Binding MachineName}" Header="Machine name" /><DataGridTextColumn Binding="{Binding IPAddress1}" Header="IP1" /><DataGridTextColumn Binding="{Binding IPAddress2}" Header="IP2" /></DataGrid.Columns></DataGrid>

The Machines Dal-Object contains a set of Machine, the properties of each machine are machinename, ipaddress1, ipaddress2. The problem is that the header it's locked!!

But if I use code below the header unlocked but I do not knowhow to read data:

<DataGrid AutogenerateColumns="False" ItemSource={Binding SelectedEntity} /><DataGrid.Columns><DataGridTextColumn Binding="{Binding MachineName}" Header="Machine name" /><DataGridTextColumn Binding="{Binding IPAddress1}" Header="IP1" /><DataGridTextColumn Binding="{Binding IPAddress2}" Header="IP2" /></DataGrid.Columns></DataGrid>

Any suggestions?

thanks in advance,

Best regards,

CS

Is there a way to make a DataGrid expand a new row, when clicking on it?

$
0
0

We've just spent the last several months working on a new WPF application, to replace an old VB6 app (thank God that's gone!) We use the DataGrid, along with the DataGridComboxBoxColumn to specify a dropdown for the user to select. In our testing we've found that you have to select something from the dropdown, and then tab through the rest of the row in the data grid (or at least go to the last column in the data grid and tab out of it), if you want to create a new row to be able to use it. Yesterday we released this new app, and it has been well received by nearly everyone.

However there is one user who doesn't tab through the row. Instead he'll select something from the dropdown and then get frustrated because the data grid doesn't give him another row so he can select something different in that other row (this is before he's finished filling out the first row). So, is there a way with the WPF DataGrid control to do what this particular user is trying to do? Some property I can set?


Rod

Staggered columns in WrapPanel or Custom Panel for ListView

$
0
0

I've been trying for a while now and I can't seem to replicate this model without using a grid. I've tried making some simple custom panels and a wrappanel that makes a new column after n pixels or n number of items which works; however, I'm unable to find a way to stagger each column.

Here's an image of what I'm trying to do:

enter image description here

I've made solutions that use a Grid that do stagger the columns however what I need is a panel that uses columns only and it must be able to be used as the itemspanel for a ListView.

Combobox in datagrid question - displaying a property of the combo in a textbox

$
0
0

I'd like to put a property of a combobox in a textbox on a datagrid.

Combo in a datagrid defined like so:

 

Xaml:

<DataGridTemplateColumn x:Name="cboPartBCPT" Header="CPT Code" Width="100" ><DataGridTemplateColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding CPT}" /></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn.CellEditingTemplate ><DataTemplate><ComboBox x:Name="cboPartBCPT"
                                                ItemsSource="{Binding Source = {StaticResource PartB_CPTLookup}}"
                                                SelectedValue="{Binding Path=CPT}"
                                                SelectedValuePath="CPT"
                                                DisplayMemberPath="CPT"
                                                           IsSynchronizedWithCurrentItem="True"></ComboBox></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn><DataGridTextColumn x:Name="PartBProcedure" Header="Procedure" Width="200"
                                            Binding="{Binding SelectedItem.ProcedureName, ElementName=cboPartBCPT}" />

PartBProcedure is always blank. What am I doing wrong?


Thanks.

WPF password strength meter?

$
0
0

Hi ya, I'm looking for some sample of info about how to implement a strength indicator along with one TextBox for a password.

My goal is clear: just show the user if the password proposed is weak, strong, or very strong. Only for their information, not being compulsory to save a password in a concrete level of difficulty

Thanks in advance,


Primary platform is Windows 7 Ultimate 64 bit along with VS 2012/Sql2k8 for WPF/SilverLight projects.

Problems updating datagrid from collection

$
0
0

I am having trouble getting datagrid to update once collection is updated. Here is my code:

C#:

public partial class MainWindow : Window
    {
        public Student student = new Student();
        public ObservableCollection<Student> studentData = new ObservableCollection<Student>();
        public MainWindow()
        {
            InitializeComponent();

            //Set initial values
            student.Name = "Whatever";
            student.CalculusMarks = 0;
            student.EnglishMarks = 0;
            student.ProgrammingMarks = 0;
            student.Percentage = 0;

            //Read values to collection
            studentData.Add(new Student { Name=student.Name, CalculusMarks = student.CalculusMarks, EnglishMarks = student.EnglishMarks, ProgrammingMarks = student.ProgrammingMarks, Percentage=student.Percentage});

            //Set data context
            datagrid1.DataContext = studentData;

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //Perform calculation
            student.Percentage = (double)(student.CalculusMarks + student.EnglishMarks + student.ProgrammingMarks) * 100 / 300;
            datagrid1.DataContext = studentData;
            datagrid1.ItemsSource = studentData;
        }

        public class Student : INotifyPropertyChanged
        {
            private string _name;
            private int _calculusMarks;
            private int _englishMarks;
            private int _programmingMarks;
            private double _percentage;

            public string Name
            {
                get
                {
                    return _name;
                }

                set
                {
                    _name = value;
                    OnPropertyChanged("Name");
                }
            }

            public int CalculusMarks
            {
                get
                {
                    return _calculusMarks;
                }

                set
                {
                    _calculusMarks = value;
                    OnPropertyChanged("CalculusMarks");
                }
            }

            public int EnglishMarks
            {
                get
                {
                    return _englishMarks;
                }

                set
                {
                    _englishMarks = value;
                    OnPropertyChanged("EnglishMarks");
                }
            }

            public int ProgrammingMarks
            {
                get
                {
                    return _programmingMarks;
                }

                set
                {
                    _programmingMarks = value;
                    OnPropertyChanged("ProgrammingMarks");
                }
            }

            public double Percentage
            {
                get
                {
                    return _percentage;
                }

                set
                {
                    _percentage = value;
                    OnPropertyChanged("Percentage");
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;    

            private void OnPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }
    }

Here is my XML:

<Grid><DataGrid Name="datagrid1" AutoGenerateColumns="False" ItemsSource="{Binding}"><DataGrid.Columns>    <DataGridTextColumn x:Name="NameCol" Header="Name" Width="*" Binding="{Binding Path=Name, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/><DataGridTextColumn x:Name="CalculusMarksCol" Header="Calculus" Width="*" Binding="{Binding Path=CalculusMarks, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/><DataGridTextColumn x:Name="EnglishMarksCol" Header="English" Width="*" Binding="{Binding Path=EnglishMarks, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/><DataGridTextColumn x:Name="ProgrammingMarksCol" Header="Programming" Width="*" Binding="{Binding Path=ProgrammingMarks, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/><DataGridTextColumn x:Name="PercentageCol" Header="Percentage" Width="*" Binding="{Binding Path=Percentage, Mode=TwoWay, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/></DataGrid.Columns></DataGrid><DockPanel LastChildFill="False"><Button Content="Update" Height="50" Width="75" Margin="5" DockPanel.Dock="Bottom" Click="Button_Click" /></DockPanel></Grid>

Any ideas on what I'm doing wrong???

Drawing multiple lines from a loop

$
0
0

Hopefully this is the right forum.

I've only been programming for a few days.

So I have this little C# program that draws a nice pattern. In WinForms the main code is

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rect = this.ClientRectangle;
            int cx = rect.Width;
            int cy = rect.Height;
            float scale = (float)cy / (float)cx;
            Pen pen = new Pen(Color.Black);
            for (int x = 0; x < cx; x += 7)
            {
                g.DrawLine(pen, 0, x * scale, cx - x, 0);
                g.DrawLine(pen, 0, (cx - x) * scale, cx - x, cx * scale);
                g.DrawLine(pen, cx - x, 0 * scale, cx, (cx - x) * scale);
                g.DrawLine(pen, cx - x, cx * scale, cx, x * scale);
            }
            g.Dispose();
            pen.Dispose();
        }

And in WPF my code is

public MainWindow()
        {
            InitializeComponent();

            for (int x = 0; x < myCanvas.Width; x+=7)
            {
                var myLine1 = new Line();
                myLine1.StrokeThickness = 1;
                myLine1.Stroke = Brushes.Black;
                myLine1.X1 = 0;
                myLine1.Y1 = x;
                myLine1.X2 = myCanvas.Width - x;
                myLine1.Y2 = 0;
                myCanvas.Children.Add(myLine1);

                var myLine2 = new Line();
                myLine2.StrokeThickness = 1;
                myLine2.Stroke = Brushes.Black;
                myLine2.X1 = 0;
                myLine2.Y1 = myCanvas.Width - x;
                myLine2.X2 = myCanvas.Width - x;
                myLine2.Y2 = myCanvas.Width;
                myCanvas.Children.Add(myLine2);

                var myLine3 = new Line();
                myLine3.StrokeThickness = 1;
                myLine3.Stroke = Brushes.Black;
                myLine3.X1 = myCanvas.Width - x;
                myLine3.Y1 = 0;
                myLine3.X2 = myCanvas.Width;
                myLine3.Y2 = myCanvas.Width- x;
                myCanvas.Children.Add(myLine3);

                var myLine4 = new Line();
                myLine4.StrokeThickness = 1;
                myLine4.Stroke = Brushes.Black;
                myLine4.X1 = myCanvas.Width - x;
                myLine4.Y1 = myCanvas.Width;
                myLine4.X2 = myCanvas.Width;
                myLine4.Y2 = x;
                myCanvas.Children.Add(myLine4);
            }
        }

How do I reduce the amount of code in the WPF version?

Thanks.

Marcus



Filtering through multiple ListView WPF

$
0
0

I'm creating an application that uses WPF, MVVM and using the singleton pattern. I have an issue however when trying to filter through a list.

Here is my scenario of using the singleton pattern and using it within my application. I have a School, and a Course; 

SchoolListViewModel -> SchoolViewModel -> CourseViewModel

The image below show three different section. Section 1 shows a list of Schools that uses a filter. Section 2 is a set of criteria in which I want to filter section 3. 



However, When I apply the following code it some how does not load any course data at all nor does it filter through the list using a name search.

Could anyone enlighten me or point out what I am doing wrong or if I am doing is correct?

Thanks in advance.

How to license a wfp application?

$
0
0

We developed a wpf application, and would like to assign the license for it to sell. How to do license management, such as serial number, hardware integration, etc... 

Any ideas and/or hyperlinks for it? Thanks.

ObservableCollection not firing proper CollectionChanged event

$
0
0

WPF and EntityFramework 6
I've created entity Customer, then in CustomerViewModel I've implemented ObservableCollection and subscribed to event CollectionChanged.
In mainWindow DataGrid.ItemsSource is assigned to Customers ObservableCollection. As far as I know, it is reference type.

Then, for testing purposes I'm adding new Customer and adding it to customerView.Customers collection.

Why it fires collectionchanged event in mainWindow? I'm changing collection in viewModel. Seems like connection between Datagrid and viewmodel is broken. (But, after adding item, it is saved to database and presented in UI)

what I want to achieve is adding items to database when entering new row in Datagrid manually. Any ideas how to fix it?

Edit:Maybe my entity Customer should implement INotifyPropertyChanged instead of ViewModel?

   public class CustomerViewModel : ObservableObject
    {
        private Customer Customer = new Customer();
        private Context ctx;
        public Context Context
        {
            get
            {
                return ctx;
            }

        }
     
        public CustomerViewModel()
        {
            ctx = new Context();
            Customers = new ObservableCollection<Customer>();
            Customers.CollectionChanged += OnCollectionChanged;
        }

        private void OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            MessageBox.Show("Test");
        }

        public ObservableCollection<Customer> Customers
        {
            get
            {
                return Customer.Customers;
            }
            set
            {
                if (Customer.Customers != value)
                {
                    Customer.Customers = value;
                    RaisePropertyChanged("Customers");
                }
            }
        }

        public int CustomerNumber
        {
            get
            {
                return Customer.CustomerNumber;
            }

            set
            {
                if (Customer.CustomerNumber != value)
                {
                    Customer.CustomerNumber = value;
                    RaisePropertyChanged("CustomerNumber");
                }

            }

        }

        public ObservableCollection<Customer> getAllCustomers()
        {
                ctx.Customers.Load();
                Customer.Customers = ctx.Customers.Local;
                return Customer.Customers; 
        }
	}

		CustomerViewModel viewModel = new CustomerViewModel();
        public MainWindow()
        {
            InitializeComponent();       
        }

        private void Main_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                DataGrid1.ItemsSource = viewModel.getAllCustomers();
                ((INotifyCollectionChanged)DataGrid1.Items).CollectionChanged += OnCollectionChanged;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
            }            
        }

        private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            MessageBox.Show("Test2");
        }
		private void RibbonButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                viewModel.Customers.Add(new Customer { CustomerNumber = 214 });            
                viewModel.Context.SaveChanges();              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }            
        }


Touch Move events not working for child when Touch Move event of parent is working

$
0
0

When Moving touch on Window Touch Move of Window is called but when touch move reaches Child (Ellipse)

Touch Move event is not fired But I atleast I want to identify if the Touch is on Ellipse or not. as it it works on mouse move

This is my Xaml code

<Window x:Class="TouchEvent.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" IsManipulationEnabled="True" TouchMove="Window_TouchMove">


    <Canvas Name="MainCanvas" Height="350" Width="525" Background="Gray" >
        <!--
        The ellipse that will be dragged around.
        The Top and Left attributes must be set
        or Canvas.GetTop and Canvas.GetLeft will return NaN.
        -->
        <Ellipse IsManipulationEnabled="True"
            Name="DragEllipse"
            Canvas.Top="0" Canvas.Left="0"
            Fill="Red"
            Width="100" Height="100"
            TouchDown="DragEllipse_TouchDown"
            TouchMove="DragEllipse_TouchMove"
            TouchLeave="DragEllipse_TouchLeave"
            >
        </Ellipse>
    </Canvas>
</Window>

This is my .CS Code


        // Declare the global variables.
        TouchDevice ellipseControlTouchDevice;
        Point lastPoint;

        private void DragEllipse_TouchDown(object sender, TouchEventArgs e)
        {
            // Capture to the ellipse.  
            e.TouchDevice.Capture(this.DragEllipse);

            // Remember this contact if a contact has not been remembered already.  
            // This contact is then used to move the ellipse around.
            if (ellipseControlTouchDevice == null)
            {
                ellipseControlTouchDevice = e.TouchDevice;

                // Remember where this contact took place.  
                lastPoint = ellipseControlTouchDevice.GetTouchPoint(this.MainCanvas).Position;
            }

            // Mark this event as handled.  
            e.Handled = true;
        }

        private void DragEllipse_TouchMove(object sender, TouchEventArgs e)
        {
            if (e.TouchDevice == ellipseControlTouchDevice)
            {
                // Get the current position of the contact.  
                Point currentTouchPoint = ellipseControlTouchDevice.GetTouchPoint(this.MainCanvas).Position;

                // Get the change between the controlling contact point and
                // the changed contact point.  
                double deltaX = currentTouchPoint.X - lastPoint.X;
                double deltaY = currentTouchPoint.Y - lastPoint.Y;

                // Get and then set a new top position and a new left position for the ellipse.  
                double newTop = Canvas.GetTop(this.DragEllipse) + deltaY;
                double newLeft = Canvas.GetLeft(this.DragEllipse) + deltaX;

                Canvas.SetTop(this.DragEllipse, newTop);
                Canvas.SetLeft(this.DragEllipse, newLeft);

                // Forget the old contact point, and remember the new contact point.  
                lastPoint = currentTouchPoint;

                // Mark this event as handled.  
                e.Handled = true;
            }
        }

        private void DragEllipse_TouchLeave(object sender, TouchEventArgs e)
        {
            // If this contact is the one that was remembered  
            if (e.TouchDevice == ellipseControlTouchDevice)
            {
                // Forget about this contact.
                ellipseControlTouchDevice = null;
            }

            // Mark this event as handled.  
            e.Handled = true;
        }

        private void Window_TouchMove(object sender, TouchEventArgs e)
        {
            if (e.Source.GetType() != typeof(TouchEvent.MainWindow))
            {

            }
        }


    }
}

OpenGL Rendering with WPF

$
0
0

Hi

I have read the other post and forum on using windows form host control on how to Render OpenGL in WPF.

I am using a CAD kernel(Open cascade) based on C++ and i have created C# wrappers using SWIG.

I am able to run CAD viewer (based on OpenGL  provided by open cascade) in winform and using host control in WPF too.

I am bit curies to understand what will happen if i directly pass WPF MainWindow handle into SWIG wrapper class(without form host control). i did the same i have noticed following behavior as shown in image. 

After few seconds the window rendered with white layer (OpenGL drawing got erased by white color as i understood. My understanding could be wrong also)

I would like to know why / how the opengl painting (based on GDI) taken place initially and then its replaced  with WPF presentation layer.

Code Snippet

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using OCCWrappers.View;
using OCCWrappers.AIS;
using OCCWrappers.Quantity;
using OCCWrappers.Aspect;
using System.Windows.Interop;

namespace OCCTestWPF
{
    /// <summary>
    /// Interaction logic for OCCWPF.xaml
    /// </summary>
    public partial class OCCWPF : Window
    {
        Display3d display;
        Handle_V3d_Viewer _hViewer;
        Handle_V3d_View _hView;
        V3d_Viewer _viewer;
        V3d_View _view;
        Handle_AIS_InteractiveContext _hContext;
        AIS_InteractiveContext _context;

        public OCCWPF()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(OCCWPF_Loaded);
        }

        void OCCWPF_Loaded(object sender, RoutedEventArgs e)
        {
            IntPtr _handle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
            SetUpOcc(_handle);
            
        }
        protected override void OnRender(DrawingContext drawingContext)
        {
            //base.OnRender(drawingContext);
        }

        private void SetUpOcc(IntPtr Handle)
        {
            display = new Display3d();
            display.Init(Handle);
            _hViewer = display.GetViewer();
            _viewer = _hViewer.GetObject();
            _viewer.SetDefaultLights();
            _hView = display.GetView();
            _view = _hView.GetObject();
            display.Test();
            display.TestCircle();
            display.ShowCoordinateAxis();
            _view.SetProj(V3d_TypeOfOrientation.V3d_Xneg);
            _view.SetBackgroundColor(Quantity_NameOfColor.Quantity_NOC_BLACK);
            _view.FitAll();
            _view.TriedronDisplay(Aspect_TypeOfTriedronPosition.Aspect_TOTP_LEFT_LOWER, Quantity_NameOfColor.Quantity_NOC_WHITE, 1e-1, V3d_TypeOfVisualization.V3d_ZBUFFER);
            _view.Update();
            _hContext = display.GetContext();
            _context = _hContext.GetObject();
        }
    }
}

There are no WPF project templates for C++

$
0
0
Why can't I find any WPF Application templates for C++ neither among installed templates nor online?

WPF Image Source

$
0
0

I couldn't find anything that matched although I found ways to get this to work another way.  My problem is I'm following along a youtube video on using WPF for designing and I was trying to use Visual Studio 2012 C# to try and add an Image to the form and set the Source to a file.  I dropped the Image object onto the form and then went to Common > Source in the Properties but it did not provide me with a direct 'Browse' option (the video I was watching had '...').  I was able to type in the path that I wanted but I didn't know if there was some setting I needed to check/uncheck or if there was a different way to do it in Visual Studio 2012 compared to whatever version was in the video?  Thanks for any help.


Convert String to GlyphIndices

$
0
0

Hi: What is the best way to convert a string to the unicode numbers in order to create a string of them so you can place them into the

GlyphIndices property of a glyphrun?

Here is the method I will be using it in.

 public static XElement DrawingTextXml(string userText, int userThickness, SolidColorBrush userColor)
        {
            //string for color
            String strColor = userColor.ToString();
            //convert user text to unicode numbers
            String convertedIndices = ConvertTextToIndices(userText);
            //glyph indices
            //String indices = "43 72 79 79 82 3 58 82 85 79 71";
            //base line origin
            String baseLine = "0,12.29";
            // font rendering EM size
            String emSize = "13.333333333333334";
            //device font name
            String dfName = "{x:Null}";
            //advanced widths
            String advancedWidths = "9.62666666666667 7.41333333333333 2.96 2.96 7.41333333333333 3.70666666666667 12.5866666666667 7.41333333333333 4.44 2.96 7.41333333333333";
            //BidiLevel
            String bidiLevel = "0";
            //font URI
            String fontURI = @"C:\WINDOWS\Fonts\TIMES.TTF"; 

            XElement myXml = new XElement(rootNS + "GlyphRunDrawing",
                                                        new XAttribute("ForegroundBrush", strColor),
                                                        new XElement(rootNS + "GlyphRunDrawing.GlyphRun",
                                                            new XElement(rootNS + "GlyphRun",
                                                                new XAttribute("CaretStops", "{x:Null}"),
                                                                new XAttribute("ClusterMap", "{x:Null}"),
                                                                new XAttribute("IsSideways", "False"),
                                                                new XAttribute("GlyphOffsets", "{x:Null}"),
                                                                new XAttribute("GlyphIndices", convertedIndices),
                                                                new XAttribute("BaselineOrigin", baseLine),
                                                                new XAttribute("FontRenderingEmSize", emSize),
                                                                new XAttribute("DeviceFontName", dfName),
                                                                new XAttribute("AdvanceWidths", advancedWidths),
                                                                new XAttribute("BidiLevel", bidiLevel),
                                                                new XElement(rootNS + "GlyphRun.GlyphTypeface",
                                                                    new XElement(rootNS + "GlyphTypeface",
                                                                        new XAttribute("FontUri", fontURI))))));


            return myXml;


        }

This is the method I am trying to create.

 private static String ConvertTextToIndices(String userText)
        {
            String outputString;
            Encoding unicode = Encoding.Unicode;
            Double charNumber;
            StringBuilder myIndiceString = new StringBuilder(userText.Length+1);
            myIndiceString.Length = userText.Length;
            //char myChar;

            //SByte[] arrayUniChar = new SByte[userText.Length+1];
            try
            {
                // Convert the string into a byte array. 
                //byte[] unicodeBytes = unicode.GetBytes(userText);
                char[] charNumArray;
                // Convert the new byte[] into a char[] and then into a string.
                //create the char array
               //char[] unicodeChars = new char[unicode.GetCharCount(unicodeBytes, 0, unicodeBytes.Length)];
                //put the string into the char array
               // unicode.GetChars(unicodeBytes, 0, unicodeBytes.Length, unicodeChars, 0);
                //convert each char numeric value to a string and add it to the output string
                for (int charIndex = 0; charIndex < userText.Length; charIndex++)
                {
                    charNumber = char.GetNumericValue(userText, charIndex);
                    charNumArray[charIndex] = Convert.ToChar(charNumber);

                }
                
                
                
               // string unicodeString = new string(unicodeChars);
               // return unicodeString;
                              
            }


Mike Gallinger C.Tech. Cutting Edge Computing Software Developer

ListBox ItemTemplate style?

$
0
0

hi all,

      i need a listbox style like below image,

using itempanel template.

in my listbox has 2 rows only and n columns.

it should be ordered like 

1 2 3 4 9   10 11  12

5 6 7 8 13 14 15  16

is that possible?


List box selection changed issue

$
0
0

HI,


I'm using D&D events from list box to text box which is working fine but some times when you are choose item from

the list box and the item marked as with blue line nothing happen,you cannot drag the item .I have put break-point in

the following method and usally it stops there when everting is working well but sometimes the break-point

is not invoked when the blue line is marked ,what could be the reason for such behavior ?

Im using the following code.

        private void listbox_SelectionChanged(object sender, RoutedEventArgs routedEventArgs)
        {
            if (sender is ListBox)
            {
                var listBox = sender as ListBox;

                if (listBox.SelectedItem != null)
                {
                    var mySelectedItem = listBox.SelectedItem as User;

                    if (mySelectedItem != null)
                    {
                        DragDrop.DoDragDrop(listBox, mySelectedItem,
                                            DragDropEffects.Copy | DragDropEffects.Move);
                    }
                }
            }
        }

Trigger a WPF hidden UI from a Lync client

$
0
0
Hi I need to trigger a WPF Dll from a share desktop button click from the Lync client. example A and B are on chat, there may a conference conversation, now clicks the share desktop button in the Lync client. this WPF dll (Window hidden) should be invoked with the click event. Note we are not making a Lync API using WPF, the app would be hidden from users and Users will user lync client. Please suggest if this is possible and or if there is another way to implement this. This is reverse, lync client will invoke a dll.

LostFocus event of usercontrol should fire only when focus moves out of usercontrol.

$
0
0

I have a User Control that has several children elements, including checkboxes and textboxes.

I would like to trigger the LostFocus event for my User Control only when the focus is lost on the entire User Control (e.g. clicking a button outside of the User Control).

Currently, the LostFocus event is also triggering when I move between children elements of my User Control, e.g. from one textbox to another.


Viewing all 18858 articles
Browse latest View live


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