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

use Binding ElementName=controlName in subcontrol while controlName is in parent control

$
0
0

Hi,

I have a control which has subcontrol and subcontrol has other subcontrol like this:

<UserControl>

<TabControl Height="140" Width="499"><TabItem Header="Tool"><c:ToolConfig DataContext="{Binding Tool}"></c:ToolConfig></TabItem>

in the ToolConfig control, I want to bind the visiblity of a Button to the visibility of  some Grid in the UserControl. How to use the Binding ElementName=GridName, Path=Visibility? should I add something like FindAncestor?

Thanks.

   


Qun Li


SAPBusinessObjects.WPF.Viewer (Object reference not set to an instance of an object.)

$
0
0

I have an issue with making Crystal Report working, when i try to update the data of the report. When the WPF window opens it works fine and i have no problems but when i try to do a refresh of the data it give me this error :

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=SAPBusinessObjects.WPF.Viewer

I started to do this project in VS 2012 but had to change back to VS 2010 because win32 for XP is not supported.

If make this windows.form project i dont have any problems with my code. it's only in WPF.

Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Imports Scs.ChemicalReportViewer Imports System.Data Class MainWindow Private crChemicalReport As New ChemicalReport Private objQryCmd As New Data.QryCmd Private objChemicalReportDB As New Data.ChemicalReportViewerDB Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Application.Current.Shutdown() End Sub Private Sub mnuRefresh_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Call GetReportData() End Sub Public Sub New() ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. crvMainReportView.Owner = Me End Sub Private Sub GetReportData() Dim dt As DataTable = New DataTable Dim qryTemp As String = String.Empty Try 'If Not IsNothing(crChemicalReport) Then ' crChemicalReport.Dispose() 'End If 'Gets the select query for the chemical report qryTemp = objQryCmd.QueryGetReportByDate(CDate("2013-02-11"),
CDate("2013-02-11")) 'Gets the records from the database dt = objChemicalReportDB.GetReportByDate(qryTemp) 'Checks to see if there are any records found in the datatable If dt.Rows.Count = 0 Then Else 'Set the data source for the report crChemicalReport.SetDataSource(dt) 'Displays the Current Datatable in the report crvMainReportView.ViewerCore.ReportSource = crChemicalReport End If Catch exCrystalReport As CrystalReportsException MessageBox.Show(exCrystalReport.ToString) Catch exSystem As Exception MessageBox.Show(exSystem.ToString) End Try End Sub Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded crvMainReportView.Owner = Window.GetWindow(Me) Call GetReportData() End Sub Private Sub crvMainReportView_Refresh(source As Object, e As SAPBusinessObjects.WPF.Viewer.ViewerEventArgs) Handles crvMainReportView.Refresh Call GetReportData() End Sub End Class

When the "Object reference not set to an instance of an object." is thrown, it is on this part of the code in the Application.g.vb

    '''<summary>
    '''Application Entry Point.
    '''</summary><System.STAThreadAttribute(),  _
     System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")>  _
    Public Shared Sub Main()
        Dim app As Application = New Application()
        app.InitializeComponent
        app.Run <-- where the "System.NullReferenceException was unhandled"
    End Sub

This was the same place in VS 2012 it was happening, any Ideas of how I can get around this?

I am also using CR for VS 13.0.5 version.

I might be able to give you IntelliTrace, also.

thank you in advance and for any help

Shane


Manipulation event and panning mode simultaneously in Scrollvewer.

$
0
0
I am developing a WPF for touch enabled device. I am facing a strange problem. My XAML structure is

     <ScrollViewer>
         <StackPanel orientation="Horizontal">
             <!--  Control goes here -->
          </StackPanel>
      <ScrollViewer>

Now

 1.  To enable scrolling on touch I have to set PannigMode toHorizontalOnly
 2.  To receive manipulation events I have to set PannigMode toNone

Problem is I have to have these two functionality simultaneously.

Is there any work around so that the scrollviewer is scrolled on touch and also themanipulationcompleted event fires.

Please help.

Scrolling of a listbox inside another listbox

$
0
0

I have a listbox (with normal vertical orientation), each element of which is a listbox with horizontal orientation. I want to have a ScrollBar inside of internal listbox.

My code is:

<Window.Resources><HierarchicalDataTemplate x:Key="ItemTemplateSchedule"><ListBox><ListBox.ItemsPanel><ItemsPanelTemplate><StackPanel Orientation="Horizontal" /></ItemsPanelTemplate></ListBox.ItemsPanel><ListBoxItem>My-Very-Long-Item-Nimber-1___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Nimber-2___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Nimber-3___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Nimber-4___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Nimber-5___</ListBoxItem></ListBox></HierarchicalDataTemplate></Window.Resources><Grid><ListBox ItemTemplate="{StaticResource ItemTemplateSchedule}" >></ListBox></Grid>

So, I have a solution for this question - I need set the width property for internal listbox according of current width of outer listbox :

Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}, Path=ActualWidth}"

Now I want add some new control in each row of outer listbox:

<HierarchicalDataTemplate x:Key="ItemTemplateSchedule"><StackPanel Orientation="Horizontal" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}, Path=ActualWidth}"><TextBlock Text="This is Text in a TextBlock"/><ListBox ><ListBox.ItemsPanel><ItemsPanelTemplate><StackPanel Orientation="Horizontal" /></ItemsPanelTemplate></ListBox.ItemsPanel><ListBoxItem>My-Very-Long-Item-Number-1___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Number-2___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Number-3___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Number-4___</ListBoxItem><ListBoxItem>My-Very-Long-Item-Number-5___</ListBoxItem></ListBox></StackPanel></HierarchicalDataTemplate>

And now it doesn't work! Now I have a Scrollbar in outer listbox again...

So, can I solve this problem? Any ideas?

Get Parent and Cast of Its Type

$
0
0

I got two wpf forms (user controls MainFormA and MainFormB) and share the same subform (another user contorl SubFormC)

MainFormA and MainFormB are similar in some parts

I access the parent from SubFormC

Grid grid_Form = (this.Parent as Grid);
MainFormA mainFormA = (grid_Main.Parent as MainFormA);
mainFormA.status = "Modified";

so I can access variable and functions in mainFormA/B.

In this case, I have to specify the parent to MainFormA. However, I would like to auto detect the type of parent

is this must use two cases to do? or there is a more general way?

Grid grid_Main = (this.Parent as Grid);
if (grid_Main.Parent.GetType().ToString() == "MainFormA") {
MainFormA mainForm = (grid_Main.Parent as MainFormA);
mainForm.status = "Modified";
....
} else {
MainFormB mainForm = (grid_Main.Parent as MainFormB);
mainForm.status = "Modified";
...
}

Thanks.



WPF Image Background issue

$
0
0

HI,

I have BitmapSource from physical image.

private void RenderImage(BitmapSource source, DrawingContext dc, Rect imageRect, bool isPrinting)
        {

I use Image object to create Image from bitmapsource:

 Image bgImage = new Image() { Source = source };

}

Is there any way I can find out that my image is transparent of it has white background. There are 1000 images in my project and I want to find out for each.

I also have to make sure that solution of this wont cause performance issue.

Thanks

Dee

Binding ImageSource from String

$
0
0

I would like to bind string form my custom dependency onject  to my button style template.

In my Dictionary.xaml

<Style x:Key="{x:Type local:myButton}" TargetType="{x:Type local:myButton}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type local:myButton}"><Border x:Name="Border" CornerRadius="2" BorderThickness="0" Padding="5"><Image Name="image" Source="{Binding ImageSource, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type local:myButton}}}"></Image></Border></ControlTemplate></Setter.Value></Setter></Style>

Class with my dependency property

        public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(string),
typeof(myButton), new PropertyMetadata());

        public string ImageSource
        {
            get { return (string)GetValue(ImageSourceProperty); }
            set { SetValue(ImageSourceProperty, value); }
        }

In User Control, it works when ImageSource is as follow

<my1:myButton ImageSource="/ApplicationName;component/Images/buttonImage.png" Content="Button Text" x:Name="myButton1"  />

I would like to have it much sorter, just the file name to make it works

<my1:myButton ImageSource="buttonImage.png" Content="Button Text" x:Name="myButton1"  />
Any suggestion? Thanks


Notify Any UIElement below UIElement That Raises Notifiction In VisualTree

$
0
0

Hello everybody,

I would like to know does an event route from the root to all leaf? Lets say I have a Button and Textblock. Button is close to the top level while Textblock is somewhere in the depth of VisualTree. Now I am using EventManager.RegisterClassHandler inside Textblock to register an handler of an event which should get called when Button raises the certain event. Will the handler get called even when button is somwhere at top level of VisualTree? 

Here is code and its not working. Maybe the RoutedEvent are the wrong approach for this:

<Style TargetType="{x:Type local:MyButton1}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type local:MyButton1}"><Button><local:MyTextBlock1 Text="Not working yet."/></Button></ControlTemplate></Setter.Value></Setter></Style></Window.Resources><Grid><local:MyButton1 x:Name="myButton1" Width="200" Height="40" Click="MyButton_Click"/></Grid>


private void MyButton_Click(object sender, RoutedEventArgs e)
        {
            this.myButton1.RaiseDoSomething();
        }


class MyButton1 : Button
    {
        public static readonly RoutedEvent PreviewDoSomethingEvent = EventManager.RegisterRoutedEvent("DoSomething", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(MyButton1));

        public event RoutedEventHandler PreviewDoSomething
        {
            add { AddHandler(PreviewDoSomethingEvent, value); }
            remove { RemoveHandler(PreviewDoSomethingEvent, value); }
        }

        public void RaiseDoSomething()
        {
            this.RaiseEvent(new RoutedEventArgs(PreviewDoSomethingEvent));
        }
    }

    class MyTextBlock1 : TextBlock
    {
        static MyTextBlock1()
        {
            EventManager.RegisterClassHandler(typeof(MyTextBlock1), MyButton1.PreviewDoSomethingEvent, new RoutedEventHandler(OnDoSomething));
        }

        public static void OnDoSomething(object sender, RoutedEventArgs e)
        {
            MyTextBlock1 txtBlock = sender as MyTextBlock1;
            if (txtBlock != null)
            {
                txtBlock.Text = "It worked! Yay!";
            }
        }
    }

As you can see MyButton is close to the top of the VisualTree and MyTextBlock is somewhere deep down. Still I wish once I click on MyButton to also call the registered handler to the event from MyTextblock. The text should then be changed to "It worked yay".

How do I do this? How to go top down the VisualTree and notify via events? The code I just posted is not working. There must be something that I am missing.









ScrollBar: no difference between "Hidden" and "Disabled"

$
0
0

I wanted to disable the mouse wheel scrolling when the cursor is over an element in WPF.


If the mouse is over the red rectangle, the parent scrolViewer scrolling (by mouse wheel) should be disabled (the red rectangle is on the scrollviewer).

I tried to use:

ScrollBarVisibility.Disabled;

by code, but the scroll bars disappear.

I would like to keep the scroll bars visibles while scrolling is disabled.

I don't want to use: 

e.Handled = true;

on my "MouseWheel" event because I have to rise the "MouseWheel" event on my red rectangle.

Any ideas ?

Update:

Here is my xaml code:

<ScrollViewer x:Name="scrollViewer" 
	helpers:SizeObserver.Observe="True"
	helpers:SizeObserver.ObservedWidth="{Binding ScrollViewerWidth, Mode=OneWayToSource}"
	helpers:SizeObserver.ObservedHeight="{Binding ScrollViewerHeight, Mode=OneWayToSource}"
	VerticalScrollBarVisibility="Auto"
	HorizontalScrollBarVisibility="Auto"
	PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"
	MouseDown="ScrollViewer_MouseDown" 
	MouseUp="ScrollViewer_MouseUp" 
	MouseMove="ScrollViewer_MouseMove" 
	PanningMode="Both">

The C# PreviewMouseWheel function:

private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{	
	if (IsMouseOverRedRectangle)
	{
		scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
		scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
	}
	else
	{
		scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
		scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
	}
}

And the MouseWheel event on my RedRectangle model:

void RedRectangle_MouseWheel(object sender, MouseWheelEventArgs e)
{
	MyValue += e.Delta;
}

As you can see, I use:

scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;

to "freeze" the scrollViewer scroll. But the scrollbars disappear, like if I used:

scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;






Using EF5, how to check if ObservableCollection has changes?

$
0
0

Hi, see code below (Using EF5).
When an item is added or removed from the datagrid the CollectionChanged event is fired and can be handled, so an IsDirty flag can be set manually. But when changing an item, the changes are not catched by the CollectionChanged event.

Question: how to check if the collection has changes and if there is a need for calling SaveChanges(). I tried to implement the PropertyChanged event on the Observable Landen collection but I couldn't get this working.

<DataGridName="dgLand"ItemsSource="{Binding}"AutoGenerateColumns="True"HorizontalAlignment="Left"Margin="36,41,0,0"VerticalAlignment="Top"RenderTransformOrigin="-2.417,-2.308"Height="187"Width="364">

In code:
private static CollectionManagerEntities context;
private ObservableCollection<tblLand> Landen;
private ICollectionView DefaultLandenView;

private void DoBinding()
{
    Landen = new ObservableCollection<tblLand>(context.tblLand);
    DefaultLandenView = CollectionViewSource.GetDefaultView(Landen);

    //CollectionChanged event
    Landen.CollectionChanged += Landen_CollectionChanged;
   
    //Binding the datagrid
    Binding myBinding_Landen = new Binding();
    myBinding_Landen.Source = Landen;
    dgLand.SetBinding(DataGrid.ItemsSourceProperty, myBinding_Landen);
}

void Landen_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Add)
    {
        foreach (tblLand myLand in e.NewItems)
        {
            context.tblLand.Add(myLand);
        }
    }
    else if (e.Action == NotifyCollectionChangedAction.Remove)
    {
        foreach (tblLand myLand in e.OldItems)
        {
            context.tblLand.Remove(myLand);
        }
    }
}

Regards Coen.


Can't get Dynamic Data Display to work! Help!!!!

$
0
0

I'm writing a program for my engineering company where I need to create a line graph that will show voltage against current for tests we run. I'm trying to use Dynamic Data Display in Microsoft Visual C# 2010 Express.

I've put all the correct references in with the DLL file and the XAML reference and I can't get it to work. I've tried on both .NET platforms 3.5 & 4. same problem each time. I

t says the type 'd3:ChartPlotter' was not found. I'm not missing the reference so what could it be?

PLEASE HELP! everyone keeps saying its easy but I can't even get my designer to load after a build!

Phoebe

LinkLable Mouse enter issue

$
0
0

In WPF, We have created a custom control ‘LinkLabel’ & User Control ‘LinkLabelMenu’, ‘LinkLabelMenuItem’. We have defined the templates for these controls and ‘LinkLabelMenu’ has inside ‘LinkLabelMenuItem’ & ‘LinkLabelMenuItem’ contains ‘LinkLabel’. We are binding the same command to mouse Click/Enter events. “Mouse Enter” event is not bubbling until once we click the link.

Please help me to troubleshoot the problems.

System.Windows.Controls Radio button and Combo Box

$
0
0

Hi All

I have a treeview, Radio buttons and combo box in window with default selection for Radio button and combo box.

Treeview should load based on radio button checked and combo box selection so I am checking combo box selection in radio button checked event and checking combo box selection in radio button checked event .

The Problem I am facing here is

in Initialization radio button checked event combobox is NULL or in combo box selection event radio button is null.

Pleaase help me I am new to WPF.

Thanks in Advance

WPF - Printig problem with a picture

$
0
0

Hi!

i have a picture that i will print..

BildOrginal = @"d:\MyPicture.jpg";

So far so good..

Now i have the Printer Dialog with a little problem...

Here is the Code:

        private void button1_Click(object sender, RoutedEventArgs e)
        {

            // Standardprinter
            LocalPrintServer StdDrucker = new LocalPrintServer();
            string StdDruckerName = StdDrucker.DefaultPrintQueue.FullName.ToString();

            // Select Printer
            PrintDialog pD = new PrintDialog();
            pD.PageRangeSelection = PageRangeSelection.AllPages;
            pD.UserPageRangeEnabled = true;

            Nullable<Boolean> print = pD.ShowDialog();
            if (print == true)
            {
                StdDrucker.DefaultPrintQueue = pD.PrintQueue;
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += PrintPage;
            //    pd.PrinterSettings.PrinterName.
                pd.Print();
           }
       }

        private void PrintPage(object o, PrintPageEventArgs e)
        {
            System.Drawing.Image img = System.Drawing.Image.FromFile(BildOrginal);
            Point loc = new Point(100, 100);
            e.Graphics.DrawImage(img, 10, 10, 900, 700);
        }
The Problem is on the point:

//    pd.PrinterSettings.PrinterName....

How can I set the printer that i become from the printer dialog?

If I let the code run then the print goes to the Standard printer...

Best Regards

Bernd

ObservableCollection Mistake?

$
0
0

Hi!

i have a bug in my source but i did not see the bug... !?

<ListView x:Name="ListViewAnsprechpartner" Margin="0,0,254,0" ItemsSource="{Binding Ansprechpatner}" IsSynchronizedWithCurrentItem="True" PreviewKeyDown="ListViewAnsp_PreviewKeyDown" SelectionChanged="ListViewAnsp_SelectionChanged" Height="506" PreviewMouseLeftButtonUp="ListViewAddresses_PreviewMouseLeftButtonUp" Canvas.Left="739" Canvas.Top="173" Width="200" AlternationCount="2" FontFamily="Arial" FontWeight="Bold" FontSize="14"><ListView.View><GridView AllowsColumnReorder="True"><GridViewColumn Width="auto" Header="Ansprechpartner                   " DisplayMemberBinding="{Binding Ansprechp1}" /></GridView></ListView.View></ListView>
...
        public ObservableCollection<WPFAnsprechpartner> Ansprechpatner { get; set; }
...
        Ansprechpartner = new ObservableCollection<WPFAnsprechpartner>();
...
    public class WPFAnsprechpartner
    {
        public string Ansprechp1 { get; set; }
    }

On this line is a Mistake:

Ansprechpartner = new ObservableCollection<WPFAnsprechpartner>();

But what is wrong?

The compiler mean it is not a String!?

See anyone the mistake?

Best regards

Bernd


WPF Tiff Image Slideshow

$
0
0

Hi,

I need to develop a WPF application which needs to display few tiff images. I need to develop a tiff image viewer which should have a button, on click of which the images in the tiff file should move like slide show. I have no idea how to do it. Any suggestions?

Thanks.


-------------kings--------------

WPF Image RBG Manipulation

$
0
0
Hi, I have a little side project that I've working on (WPF VB.Net).  Basically its generates a gradient palette for use with some third party Infrared Thermography Software because I wanted to experiment and have additional options beside the default ones supplied with the software.  All this functionality works but when I bounced it around the office, other staff wanted to see how that new gradient would appear on a test image before they hit the save button.  I am trying to take the test image and replace its pixel RGB values with that of the generated gradient and then load the adjusted image into the application.  All the info that I find re: Image Processing focuses toward the Filtering/Transforming aspects, if someone could kindly give me a push in the right dirtection then it would be graetly appreciated.

Dangerous... #UpUpCronulla

Custom Scrolling In a CustomVrtualizingTreePanel

$
0
0

Hello WPF experts!

I am wroking on few custom controls. One of them is a Panel called "CustomVirtualizingTreePanel" another is the "Tree" that is an ItemsControl with its ItemsContainers called "TreeItem". Basically the panel is there to support UI Virtualization for the Tree. The Tree itself has set the CustomVirtualizingTreePanel as its ItemsPanel and the containers called "TreeItem" also have set the CustomVirtualizingTreePanel as their ItemsPanel.

Now the problem is to make the root CustomVirtualizingTreePanel support the scrolling. I have implemented the IScrollInfo interface but I dont know how to even start programming the scrolling logic.

I managed to implement the "expanding nodes behavior" for the TreeItem and also the "generate only the visible items no matter on what level behavior" for the CustomVirtualizingTreePanel but now I am stuck at making the CustomVirtualizingTreePanel scroll. The major issue is to let the panel know what level has what offset. Thats where I was hoping somebody could help me out with ideas how it could work. The root CustomVirtualizingTreePanel  increases the offset if I start scrolling down and now I need some algorithm to inform other nested CustomVirtualizingTreePanels to recalculate their offset according to the main offset from the root. How do I do that? Any ideas?





Programmatically Set CaretPosition to a specific Inline inside a FlowDocument of a RichTextBox

$
0
0

I have a RichTextBox that contains both Text and Pictures.  I've done this using Run's and InLineUIContainer's.  I also have some buttons that will programmatically insert any number of Runs, InlineUIContainers, and Paragraphcs to the FlowDocument at the current CaretPosition.  The problem is that the CaretPosition reacts very spiratically after I insert this content programmatically.  All I want to do is have the CarretPosition set to the end of the new content I put in.  

Is there a way to get a TextPointer for the location after this new content?  I have a handle on the actual Inline that the CaretPosition has to be set for, but I don't know how to get a TextPointer there.  

The only solution I've come up with is to determine a 'Location #' of the cursor prior to inserting the content: 


        private int GetTextPointerLocation(TextPointer pPointer)
        { 
            int iLocation = -1; 

            try
            { 

                TextPointer pCurrent = this.Document.ContentStart;
                while (pCurrent != null)
                { 
                    if (pCurrent.CompareTo(pPointer) == 0)
                        break; 
                    iLocation++;
                    pCurrent = pCurrent.GetNextInsertionPosition(LogicalDirection.Forward); 
                } 
            }
            catch (Exception ex)
            { 
            } 

            return iLocation;
        }

The problem is that this is extremely slow (multiple seconds for a small amount of text - GetNextInsertionPosition is what takes all the time).

After that I get the TextPointer via this method:

public TextPointer GetTextPointerForLocation(int iLocation)
        {
            TextPointer tpReturn = this.Document.ContentStart;
            try
            {
                int iCurLocation = 0;
                while (tpReturn != null)
                {
                    if (iLocation == iCurLocation)
                        return tpReturn;
                    iCurLocation++;
                    tpReturn = tpReturn.GetNextInsertionPosition(LogicalDirection.Forward);
                }
            }
            catch (Exception ex)
            { 
            }

            return tpReturn;
        }

Which I can then use to set the CaretPosition.  The performance is just way to slow.  There has to be a faster way to set the CaretPosition to a location in reference to an Inline, or even a Paragraph.

Basically what I need, is a method that I can pass in an Inline that's inside the FlowDocument, and have it return a TextPointer at the beginning of that Inline.  

Thanks for the help!

Disable all GUI input until one method completes

$
0
0

I’m pretty new to WPF so I’m hoping this is a simple problem…

I need to disable all GUI input until a method (initiated from a button click) completes.  I do NOT want to run the method in a separate background thread.  I realize this means that my GUI will be unresponsive until the method completes but that is exactly what I need in this particular case.

I assumed this would be easy by disabling/enabling the whole window but any mouse clicks on a disabled button during the time they are disabled are simply being cached in a queue and processed once the window is re-enabled.

Is there some way to disable all input caching or clear the queue or something totally different?

Thanks.

Viewing all 18858 articles
Browse latest View live


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