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

How change behavior of WPF RelativeSource FindAncestor

$
0
0

Hi Guys,

IN my WPF application i am using telerik:RadcomboBox control and databinding. 

<telerik:RadComboBox
FontSize="11"
FontFamily="Arial"
Height="30"                                                IsEditable="True"                                            VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"                                 DisplayMemberPath="Drg1"                                     Text="{Binding DRG}"                                                                                             ItemsSource="{Binding DataContext.Drgs, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}}}"                                       SelectedItem="{Binding DRG}"                                  Style="{StaticResource CDIComboBoxStyle}"                                                 BorderThickness="0">                                <telerik:RadComboBox.ItemsPanel>                                    <ItemsPanelTemplate>                                        <VirtualizingStackPanel IsVirtualizing="True" />                                    </ItemsPanelTemplate>                                </telerik:RadComboBox.ItemsPanel>                            </telerik:RadComboBox>

Actually all works fine, but i would to have ability to find values over leading zero. For example when i type 20 it become to 020instead of 20 => 200. Like it works now. Can somebody advice me how i can achieve this ?

 


Implement Publisher subscriber without delegate and event

$
0
0

Hi,

Today One guy has asked me to implement publisher and subscriber without help of delegate and event.

I have tried like this:

1. Publisher class I have created one dictionary which hold all the property and their 

2. created one class as register class whose instance is created in publisher which will register all the subscriber class.

3. created one method in publisher class where checking all the property value

but how to inform the subscriber class about this.



vikas sharma AB

How to send touch input to different client application

$
0
0

Dear all

I am study a protyping application for a customer in order to deliver colaborative aspect of the application design.

In order to better cacth the proper foundation to use for that, the scenario is as follow:

- A project manager will connect to a hosted portal on the web where he has setup his presentation.

- Then different employee need to follow that presentation and collaborate in live with it

- The PM start to show on a touch screen for instance a project plan picture and during explaination start to ink and take some note on the plan for better understanding

- Then employee have a Windows tablette in hands and then can see directly on the tablet what the PM is showing on the touch screen ( included added annotation, and update in live)

- Then employee could also place some annotation directly from their tablet, and its refelcted on PM touch screen

What I am trying to reach:

What I am trying to do out of this is how can I get in live what is happening on touch screen to tablet and reverse. How notes taken from tablet could be send out in order to be visible on touch screen ( could be inking, text,..)

And also what technique to be used in order that Ink points, object position, touch input, gets send to others devices .

Do I have to records all touch input and serialize them and rebuild the touch sequence on the other side ?

I have no idea how to approach this and looking for proper way, knowing that it should be fast.

Thanks for your comments

regards

How to convert text to uppercase in rich text box, wpf, c#?

$
0
0

I am new to wpf. I am working on a computer application. Here is a requirement. When a user selects Uppercase from combobox, then when he types uppercase font should appear in the rich text box. End result of the text box needs mixture of uppercase lines and lowercase lines.

In simple textbox, there is character casing option but in rich text box there is no such. So how could I achieve this. Sorry for my bad english. Hope you understand my requirement.

WPF and Google Speech

$
0
0

Good Day. Please help me !!! Maybe you know how I can realize google speech recognition in my desktop solution

I want say some word, then google must return me text, and then i insert this text in text box on me WPF 

To Use another way to write it

$
0
0
            if (System.Text.RegularExpressions.Regex.IsMatch(mmH_Text.Text, "[ ^ A-Z a-z  cn  +-/*~!@#$%^&*()]") ||
                String.IsNullOrEmpty(SetKeyIn.Text) ||
                System.Text.RegularExpressions.Regex.IsMatch(SetKeyIn.Text, "[ ^ A-Z a-z +-/*~!@#$%^&*()]") )
            {
                QtyOfUpright.Text = "error";
            }

            else
            {
                QtyOfUpright.Text = Convert.ToInt32(SetKeyIn.Text) * 2 + "Pcs";
                QtyOfBasePlate.Text = Convert.ToInt32(SetKeyIn.Text) * 2 + "Pcs";
                QtyOfSpacer.Text = Convert.ToInt32(SetKeyIn.Text) * 2 + "Pcs";
                QtyOfHB.Text = Convert.ToInt32(SetKeyIn.Text) * 2 + "Pcs";
            }


if I use this way like code that show it...

is just meaning :

if (match with text)

{ //error cannot be calculate}

else

{"Calculate"}

So I want to change it to :

if (can be calculate)

{ //calculate the thing}

else

{"Text = Cannot Be Calculate"}

Have any Idea for this way?

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

$
0
0

Hi Experts,

i am find the error while run the console application. the error given below.

" A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Retrieving the COM class factory for component with CLSID {EFAC2D80-175B-11D2-9927-006097C27C31} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

If there is a handler for this exception, the program may be safely continued. "

My error is comes on the first line of the code i.e.   DFCLib.IDfClientX cx = new DFCLib.DfClientX();  the code is given below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Emc.InputAccel.QuickModule.ClientScriptingInterface;
using Emc.InputAccel.DocumentumExport.Scripting;
using Emc.InputAccel.DocumentumExport.Setup;
using DFCLib;
using System.Runtime.Versioning;
using System.Reflection;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
             DFCLib.IDfClientX cx = new DFCLib.DfClientX();
            IDfClient client = cx.getLocalClient();
            IDfSessionManager sMgr = client.newSessionManager();
            DFCLib.DfClientX clientX = new DFCLib.DfClientX();
            IDfLoginInfo loginInfo = clientX.getLoginInfo();
            loginInfo.setUser("dmadmin");

            loginInfo.setPassword("demo.demo");

            loginInfo.setDomain("");
            string strRepoName = "corp";
            sMgr.setIdentity("corp", loginInfo);
            IDfSession session = sMgr.getSession(strRepoName);
            try
            {
                IDfDocument document = (IDfDocument)session.newObject("dm_document");
                document.setObjectName("Report on Wizards");
                document.save();
            }
            finally
            {
                sMgr.release(session);
                
            }
        }
    }
}

Get maximum itemid from nested observablecollection

$
0
0

Hi

I have nested observablecollection. It contains n levels.

How to get maximum id (integer type) from this nested observablecollection, as i have to add new item at the selected node.

In order to add new item into nested observablecollection, i require the id of last item in collection.

Following is the Observablecollection:

Imports System.Collections.ObjectModel
Imports Telerik.Windows.Controls
Imports System.ComponentModel

Public Class BefundItem
    Implements INotifyPropertyChanged

    Public Event PropertyChanged As PropertyChangedEventHandler _
          Implements INotifyPropertyChanged.PropertyChanged

    Private Sub NotifyPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

    Public Sub New(Id As String, ParentId As String, text As String)
        Me.Id = Id
        Me.ParentId = ParentId
        Me.Text = text
        Me.Items = New ObservableCollection(Of BefundItem)()
    End Sub

    Private _Id As Integer
    Public Property Id() As Integer
        Get
            Return _Id
        End Get
        Set(ByVal value As Integer)
            _Id = value
            NotifyPropertyChanged("Id")
        End Set
    End Property

    Private _ParentId As Integer
    Public Property ParentId() As Integer
        Get
            Return _ParentId
        End Get
        Set(ByVal value As Integer)
            _ParentId = value
            NotifyPropertyChanged("ParentId")
        End Set
    End Property

    Private _Text As String
    Public Property Text() As String
        Get
            Return _Text
        End Get
        Set(ByVal value As String)
            _Text = value
            NotifyPropertyChanged("Text")
        End Set
    End Property

    Public ReadOnly Property IsExpandable() As Boolean
        Get
            Return True
        End Get
    End Property

    Public m_Items As ObservableCollection(Of BefundItem)
    Public Property Items() As ObservableCollection(Of BefundItem)
        Get
            Return m_Items
        End Get
        Set(value As ObservableCollection(Of BefundItem))
            m_Items = value
            Me.NotifyPropertyChanged("Items")
        End Set
    End Property

    Public Property Count() As Integer
        Get
            Return m_Count
        End Get
        Set(value As Integer)
            m_Count = value
            Me.NotifyPropertyChanged("Count")
        End Set
    End Property
    Private m_Count As Integer


End Class

Code to fetch data from observablecollection to Treelistview:

 Private Sub Fill_Befunde_Treeview()
        Try
            For j As Integer = 1 To 2
                id = j
                Parentid = 0
                text = j

                Dim parent As New BefundItem(id, Parentid, text)

                For i As Integer = 1 To 4
                    id = i
                    Parentid = j
                    text = j & "." & i

                    Dim child As New BefundItem(id, Parentid, text)
                    parent.Items.Add(child)
                Next
                data.Add(parent)
            Next

            trvlstBefunde_Befunde.ItemsSource = data
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Thank you in advance.

S.Naik


Undo Redo in WPF InkCanvas

$
0
0

Hello There, i want to perform undo and redo task  on button click in WPF Inkcanvas , could anyone please help me with a demo code.

i want to perform undo and redo on a button click in wpf inkcanvas. please help me as soon as possible.

Thanks in Advance.



Om Prakash

Microsoft Ribbon does not render in Designer anymore

$
0
0

Hello,

I'm using the Microsoft Ribbon for WPF (System.Windows.Controls.Ribbon) and VS2015. Since I removed unnecessary depencies from my project (like Dynamic Data Display etc, things not related to the ribbon) it does not render correctly in the Designer anymore. All RibbonButtons get rendered as usual buttons and so on.

I used the Clean Solution option and also rebuild multiple times, without sucess. While execution everything is fine, just the designer can't handle the ribbon anymore. What could have caused this strange behaviour?

Sadly MSDN does not allow me to include links or pictures in this post at the moment but I could send them if anyone is interested.

Greetings,
Marcel

Maintain canvas child position on resize

$
0
0

I have a mouse up event that draws an ellipse.  When the window is resized I want the balls to move and scale with the canvas - so if the ball is 10% from the top and 10% from the left, I want it to be in the same relative spot whether the canvas is 1000px wide or 50px wide.  Ideas?

            Ellipse ball = new Ellipse();
            ball.Width = 30;
            ball.Height = 30;
            ball.Fill = new SolidColorBrush(Colors.OrangeRed);

            Point p = Mouse.GetPosition(court);

            court.Children.Add(ball);
            Canvas.SetLeft(ball, p.X - (ball.Width/2.0));
            Canvas.SetTop(ball, p.Y - (ball.Height/2.0));


WPF datagrid copy to another datagrid

$
0
0

HI All

I'm trying to simple copy data from one datagrid to another using c# in WPF.  Datagrid data are loading from sql.

What i'm trying to do is to make bill of the material of some parts and when i choose the parts and press add, it will add all parts material (copy) to another datagrid.

Could anybody help me. Please.

Thank you.

How to generate rich text box dynamically, WPF, C#?

$
0
0
HI
I am new to wpf, c#.

I am working on a computer application. In this application, user can able to type. What I want to achieve is, when user reaches last line of the rich text box, a new rich text box should appear. This application is quite similar to ms word. How can I achieve this.

Able to type only when I click in rich text box, wpf c#?

$
0
0

Hi

I am developing a computer application in which user can able to type inside rich text box. I have provided the feature, when user types, the text will be left aligned which is normal alignment. But when the user presses tab key, the text should be center alignment.

The problem  is, when the user presses tab key, cursor moves to center of the page but doesnot blink. Seems like it gets freeze. Cant able to type anything. Then if, user clicks inside the rich text box, then user can able to type with text center alignment.

private void richTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (comboBox.SelectedIndex == 1)
            {
                richTextBox.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Center);


            }
private void text_pressed(object sender, KeyEventArgs ke){
if (ke.Key == Key.Tab)
                {
                    comboBox.SelectedIndex = 1;
                this.Focus();
                }
}

System.AccessViolationException + WPF (modern ui) + async (await)

$
0
0

My application is running on many computers, and has several tabs (pages).

But on a single computer, one of the tabs (pages) throws accessviolationexception.

This tab (page) is different from the others, so that there is "async- await" function.

In google I found that the problem is most likely in the computer. And offer the option of further research problem:
"How to perform a clean boot in Windows" (cant add link)
Maybe someone else knows how to solve the problem?

DependencyProperty does not listen to PropertyChanged event

$
0
0

I almost feel embarrassed to ask this, but after three hours, I have run out of ideas and patience.

Situation:

A ViewModel with properly implemented INotifyPropertyChanged with one string property.

    public class ViewModel : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

        private string _Header;
        public string Header
        {
            get { return _Header; }
            set { _Header = value; OnPropertyChanged(); }
        }

        public static ViewModel Current { get; private set; }

        public ViewModel()
        {
            Current = this;
        }
    }

A MainWindow.xaml

<Window x:Class="CollectionEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CollectionEditor"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525"><Window.Resources><local:ViewModel x:Key="ViewModel" /></Window.Resources><StackPanel DataContext="{StaticResource ViewModel}"><!--the textblock here properly updates:--><TextBlock Text="{Binding Header}" /><local:MyUserControl Header="{Binding Header, Mode=TwoWay}" /><Button Content="add" VerticalAlignment="Bottom" Click="Button_Click" /></StackPanel></Window>

With

private void Button_Click(object sender, RoutedEventArgs e)
        {
            string now = DateTime.Now.ToString();
            ViewModel.Current.Header = now;
        }

And finally a UserControl that exposes the "Header" dependency property:

<UserControl x:Class="CollectionEditor.MyUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:CollectionEditor"
             mc:Ignorable="d"x:Name="self" DataContext="{Binding ElementName=self}"
             d:DesignHeight="300" d:DesignWidth="300"><StackPanel><TextBlock Text="{Binding Header}" /></StackPanel></UserControl>

    public partial class MyUserControl : UserControl, INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregionpublic string Header
        {
            get { return (string)GetValue(HeaderProperty); }
            set
            {
                //This setter is never invoked?!
                Debugger.Break();
                SetValue(HeaderProperty, value);
                OnPropertyChanged();
            }
        }
        public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(MyUserControl), new PropertyMetadata(null));

        public MyUserControl()
        {
            InitializeComponent();
        }
    }

The INotifyPropertyChanged implementation works, because the TextBlock in the main window does update when the button is clicked.

But something is wrong with the dependency property, because the setter is never invoked and the UserControl's text block does not update.

I can't figure out what's wrong, especially because the exact same design works in UWP just fine.

What am I missing here??

thanks

Michael



Issue with app.xaml.cs to MainViewmodel communication

$
0
0
I've following code in my wpf App.xaml.cs file:

     void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)            {                var mainVM = MainWindowViewModel.Instance;                mainVM.DisplayMessage = string.Format("Something went wrong and it has been logged...If the problem persists, please contact {0}.", mainVM.NotificationsReceiver);                mainVM.DisplayMessageForegroundColor = "Red";                        e.Handled = true;        }

MainWindowViewModel.cs
   

    public string DisplayMessage            {                get                {                    return m_displayMessage;                }                set                {                    m_displayMessage = value;                    OnPropertyChanged("DisplayMessage");                                                    }            }                public string DisplayMessageForegroundColor            {                get                {                    return m_displayMessageForegroundColor;                }                set                {                    m_displayMessageForegroundColor = value;                    OnPropertyChanged("DisplayMessageForegroundColor");                    }            }


MainWindow.xaml

     <Label Content="{Binding DisplayMessage}" Foreground="{Binding DisplayMessageForegroundColor}" Grid.Column="1" HorizontalAlignment="Left" Height="33" Margin="14,660,0,0" Grid.Row="1"                VerticalAlignment="Top" Width="693" Grid.ColumnSpan="3"/>

But this does not seem to work.Although the method in app.xaml.cs is getting invoked, I dont see the error getting displayed message on the UI.What could be wrong here please?
(I'm able to see the message when I set the DisplayMessage and DisplayMessageForegroundColor properties from within MainWindowViewModel though).

Please advise.

Thanks.






How can I diable touch & mouse ink in inkcanvas?

$
0
0

 I just want to use pen ink in inkcanvas.

Is it possible? If it so, please let me know the solution :)

How to set indent of individual text in rich text box?

$
0
0

Hi

I want to set the alignment of text individually. I mean, when a user selects a combobox item, the text he is going to type should center align and must have 150 indent from left and right. I able to achieve center alignment but could not able to figure out a way to indent.

For center alignment, I am using,

richTextBox.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Center);

Now I want to set the indent. I am not sure but below code must have a solution which I cant able to figure out;

richTextBox.Selection.ApplyPropertyValue(Paragraph.TextIndentProperty, xxxxxxxxxxxxx);

Hope you understand my requirement.

Are XBAP apps going to be depriciated like SilverLight was?

$
0
0

Just wondering what the projected lifespan for MS support of XBAP apps is.  It was a real shocker when it became obvious they were moving away from Silverlight.

Thanks.

Viewing all 18858 articles
Browse latest View live


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