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

Check Japanese character is FullWidth or HalfWidth

$
0
0

Hi everyone,

I'm currently making a Japanese application. Now , I wanna make a small function to check whether a character is fullwidth or halfwidth. Can anyone help me please ?

Thank you,


I cant editing cells in datagrid in WPF

$
0
0

I have make some project in wpf data entity frameworks but I cant write or edit crells in Datagrid 

I need only one cells to edit !

<DataGrid Name="lvShitjetDetajet" FontSize="14" Margin="10,104,10,68" KeyDown="lvShitjetDetajet_KeyDown" KeyUp="lvShitjetDetajet_KeyUp"><DataGrid.Columns><DataGridTextColumn Header="Numri"  Width="70" /><DataGridTextColumn Header="Emri" Binding="{Binding Path=Emri}" Width="350" /><DataGridTextColumn Header="Sasia" Width="100"
                          IsReadOnly="False" Binding="{Binding Sasia}"></DataGridTextColumn><!--<DataGridTextColumn IsReadOnly="False" Header="Sasia"  Binding="{Binding Path=Sasia}" Width="100" />--><DataGridTextColumn Header="Çmimi per njesi" Binding="{Binding Path=CmimiPerNjesi}" Width="150"/><DataGridTextColumn  Visibility="Hidden" Header="Totali pa TVSH" Binding="{Binding Path=TotaliPaTVSH}" Width="100"/><DataGridTextColumn  Visibility="Hidden" Header="Vlera e TVSH" Binding="{Binding Path=VleraTVSH}" Width="100"/><DataGridTextColumn Header="Totali me TVSH" Binding="{Binding Path=TotaliMeTVSH}" Width="200"/><DataGridTextColumn Header="Rabati %"  Width="100"/></DataGrid.Columns></DataGrid>

When I select cells and write something I cant i have this error message 'EditItem' is not allowed for this view.

TabItem templating with overlap

$
0
0

Hi,

I'd like to template a WPF TabControl, in order to display tabitems headers like that :

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

\                             \

/______________/

The shape looks like an arrow (like a > extruded, or the icon of "fast forward" filled), and each arrow represents a step in a process. A content presenter is displayed inside the arrow to indicate the step name.

The point is, I'd like each arrow to fit to the next (with one or two pixels between them). But all templating I can see for tabcontrols keep the rectangular shape of the container. I tried to use sample grids with negative margins, but the arrow is cropped.

Please could someone give me a small example of this ? The standard ControlTemplate I get from MS site uses a TabPanel, which I cannot avoid if I want to keep the TabControl headers behavior.

Thank you in advance. 

Regex to replace all unsupported characters.

$
0
0

Hi everyone,

I'm currently making an application which makes user to register a special password.

The password must contains alphanumeric character and one special character : 

" # $ % & ' ( ) *+ , - . /
: ; < = > ? @ [ \ ] ^ _ ` { | } ~ !

I know I should use regex. But I don't know how to replace all characters but special characters above.
Please help me to keep the special characters in the string and remove all another characters : alphabet, number , ...

Thank you ,

SQL Query

$
0
0

This could be a question for a SQL forum, but I placed it here since I am working on a WPF desktop application using C#.

In my application I am reaching out to a SQL database (2008 R2) to pull in ticket information using a SQLCommand -

command = new SqlCommand("SELECT TicketID, TicketName, TicketCost, DateStart, DateEnd
FROM tblTicketsGates
WHERE RegProfile = '" + App.rp.ToString() +"' AND DateStart <= { fn Now() } AND DateEnd >= { fn Now() }
UNION ALL
SELECT TicketID, TicketName, TicketCost, DateStart, DateEnd
FROM tblTicketsGates
WHERE RegProfile = '" + App.rp1.ToString() + "'" AND DateStart <= { fn Now() } AND DateEnd >=
 { fn Now() }", connection);

This is working fine.  What I need to do now is to specify days of the week these tickets will be available.  DateStart and DateEnd are columns in the tblTicketsGates table.  I would like to add a column to the table where I am able to specify what days a ticket is available (Monday; Friday; Sunday and Wednesday; or All Days).  How to create this type of column and then how to modify the SQLCommand to retrieve the day(s).  The query I am using places the currently retrieved information into several dictionaries defined in my application which are in turned used to determine which buttons will be displayed on the screen.

I hope this is clearer than mud to someone...


The ultimate goal here is to select only those items which fall within the date range specified by DateStart and DateEndAND are listed as available on the current day of the week.

Binding of a dependency property in a userControl does't work!

$
0
0
        public static readonly DependencyProperty myTBProperty =
            DependencyProperty.Register("myTB", typeof(decimal?), typeof(TB2), new FrameworkPropertyMetadata() { BindsTwoWayByDefault = true });
        public decimal? myTB
        {
            get { return (decimal?)GetValue(myTBProperty); }
            set { SetValue(myTBProperty, value); }
        }
<TextBox Grid.Column="1" Text="{Binding myTB,Mode=TwoWay}" Width="{Binding TBWidth}"/>

The above code is for a UserControl. 

Now I used this UserControl into another UserControl like this:

<c:TB2 myText="OutSide Diameter" myTB="{Binding Di,Mode=TwoWay}" TBWidth="120"/>
        private decimal? _Di;

        public decimal? Di
        {
            get { return _Di; }
            set
            {
                _Di = value;
                NotifyPropertyChanged();
            }
        }

But when I change the Value of Di, nothing happens. I have also tried with an ordinary TextBox and it works. 

MaskedTextBox is not clearning "Incomplete" value after losing focus

$
0
0

Hi,

We have an application built in WPF having multiple pages. 

In one of the screen, I have used MaskedTextBox to store the phone number and provided the mask as 000 000-0000.

Problem Statement -

1. If I enter an incomplete value (say 6 chars only) and exit from the text box; it is not clearing the incomplete value.

2. With having 6 chars in the MaskedTextBox, if I navigate on another screen, it doesn't store the value in the db.
Note - Here I haven't applied any validation on this control.

3. Now If I came back to actual screen where this control exists, the control retains the value (but this value doesn't exists in the database).

Please help me to resolve this issue.

Thanks,

Sunil G

WPF Animation: From 0 To AutoWidth

$
0
0

Hello

In my  wpf application application, i have this . 

XAML

<Border  BorderBrush="#FF5A5A61" Background="#333333" Height="52" Margin="0,0,0,0" VerticalAlignment="Top" BorderThickness="0,0,0,0" ><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="Auto" /><ColumnDefinition Width="55" /><ColumnDefinition Width="145" /></Grid.ColumnDefinitions><Grid x:Name="SearchBar" Margin="0,0,0,0" Width="400" Background="#333333" Grid.Column="0" ><TextBox    FontSize="13"    Margin="0"  Width="400"   BorderThickness="0"    Foreground="#FF747474"    ></Grid><Grid Margin="0,0,0,0"   Grid.Column="1" ><Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="0" Name="button1" VerticalAlignment="Top" Width="50" Click="button1_Click" /></Grid><Grid Margin="0,0,0,0"   Grid.Column="2" ></Grid></Grid></Border>

i set Expand /CollapsedFunction on boutton click. Only the Grid.Column="0"is animated

C#

private void button1_Click(object sender, RoutedEventArgs e)
    {
        if (SearchBar.Height == 0)
            {


                Storyboard myStoryboard2 = new Storyboard();
                myStoryboard2.FillBehavior = FillBehavior.Stop;
                DoubleAnimation animation2 = new DoubleAnimation();
                animation2.From = 0;
                animation2.To = 400;

                animation2.Duration = TimeSpan.FromSeconds(0.5);
                Storyboard.SetTarget(animation2, this.SearchBar);
                Storyboard.SetTargetProperty(animation2, new PropertyPath("Width"));
                myStoryboard2.Children.Add(animation2);

                myStoryboard2.Begin();
                SearchBar.Height = 400;


            }
            else if (SearchBar.Height == 400)
            {

                Storyboard myStoryboard2 = new Storyboard();
                myStoryboard2.FillBehavior = FillBehavior.Stop;
                DoubleAnimation animation2 = new DoubleAnimation();
                animation2.From = 400;
                animation2.To = 0;
                animation2.Duration = TimeSpan.FromSeconds(0.5);
                Storyboard.SetTarget(animation2, this.SearchBar);
                Storyboard.SetTargetProperty(animation2, new PropertyPath("Width"));
                myStoryboard2.Children.Add(animation2);

                myStoryboard2.Begin();
                SearchBar.Height = 0;



            }
    }

It s working fine.

Now i want to Stretch the  Grid.Column="0" like this

<Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="55" /><ColumnDefinition Width="145" /></Grid.ColumnDefinitions>

I've also removed the Width="400" property, basically my SearchBar stretch when we reduce the window size.

but my  Expand /CollapsedFunction  does not work properly.

 i would like my searchbar animated from 0 to autoWidth and Reverse when we click again on button.

Thanks for your help


snake and ladder

$
0
0
can anyone provide me snake and ladder game sample in xaml with c#

Rabia (Microsoft Student Partner)

VisualTreeHelper.getParent issues in databound tree

$
0
0

I have a databound tree with two custom object types (containers and orders)

I made a prototype app that reproduces my issue.  The issue seems to be fixed in 4.5 but I can not move my app from 3.5 just yet so I'm stuck looking for a solution.

When I move containers around in the tree the parent child relationships of the TreeViewItems are not maintained correctly.

I found this issue in my style selector.  When the StyleSelector is called, I walk up the visual tree to get the UserControl(OrdersTreeView) then I inspect a property on that class to help determine which style to select.

There are alternative ways I can accomplish getting this property, but the fact that the parent child relationship is no longer accurate causes problems all over the application.  In short, if I hack in a fix for getting the "editingEnabled" property, I'm still going to have many other issues because the relationship is inaccurate. 

public class TreeViewItemContainerStyleSelector : StyleSelector
    {
        public Style FolderEditableStyle { get; set; }
        public Style FolderNotEditableStyle { get; set; }
        public Style OrderEditableStyle { get; set; }
        public Style OrderNotEditableStyle { get; set; }
        public override Style SelectStyle(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            bool isPurchaseOrder = element.DataContext.GetType() == typeof(PurchaseOrder);

            DependencyObject source = container;
            while (source != null && !(source is OrdersTreeView))
                source = VisualTreeHelper.GetParent(source);
            bool editingEnabled = (source as OrdersTreeView).editingEnabled;

            if (editingEnabled)
            {
                if (isPurchaseOrder)
                {
                    return OrderEditableStyle;
                }
                else
                {
                    return FolderEditableStyle;
                }
            }
            else
                if (isPurchaseOrder)
                {
                    return OrderNotEditableStyle;
                }
                else
                {
                    return FolderNotEditableStyle;
                }


        }

    }


Below is a detailed description of my issue.

-root
     -container1
          -container1.1
          -container1.2
     -container2
          -container2.2

Firstly, I have an ObservableCollection<object> as the tree's item source. 

I've got drag and drop functionality coded up, and when I drag container1.1 to root it moves successfully.  below is a snippet of the code to move the objects.

public void ucOrdersTreeView_editContainer(int containerID, int parentContainerID)
        {
            ...
            ...
            ...

            if (containerToMove.parentID != newParent.ID)
            {
                currentParent.children.Remove(containerToMove);
                newParent.children.Add(containerToMove);
            }

        }

If you refer to the first snippet, the StyleSelector code functions correctly during this move, it walks the tree and chooses the correct style.

Now the tree is in this state, with container1.1 as a child of root.

-root
     -container1
          -container1.2
     -container2
          -container2.1
     -container1.1

My issue now arises if I try to add any object as a child of the container I just moved.  If i drag container1.2 into container 1.1 or I try to add a new container to container1.1 I see the issue.

The issue is that if I inspect the TreeViewItem for container1.1, it's VisualTreeHelper.GetParent("container1.1") returns null.

As I stated above, this issue seems to be resolved in .NET4.5.  Is there a work around I can use to get the visual tree in the correct state without rebinding the TreeView to my ObservableCollection?

Thanks,

Zach

I have a small sample application that reproduces this issue but I could not find a simple way to attach the zip file to this form.  I can send it on request.  


Zach Steffens


Setting the layout transfrom of image without creating a new matrixtransform

$
0
0

I have the following code for xaml:

         

         <Grid Name="navigationGrid" Grid.RowSpan="2">
        <ScrollViewer Name="scrollViewer" Grid.Row="0"
                      HorizontalScrollBarVisibility="Hidden"  VerticalScrollBarVisibility="Hidden"
                      k:KinectRegion.IsHorizontalRailEnabled="true"

                      k:KinectRegion.IsVerticalRailEnabled="true"
                      k:KinectRegion.ZoomMode="Enabled" LayoutUpdated="scrollViewer_LayoutUpdated" >
            <Image Name="navigationImage" RenderTransformOrigin="0.5, 0.5"/>
        </ScrollViewer>
       </Grid>

Now I would like to change the zoom of the image manually i.e. suppose to a zoom value Z , so I do the following:

      System.Windows.Media.Matrix m = navigationImage.LayoutTransform.Value;
       m.ScaleAtPrepend(Z / m.M11), Z / m.M11, m.M21, m.M22);                      //Z is the zoom value
       navigationImage.LayoutTransform = new System.Windows.Media.MatrixTransform(m);

But after performing layoutTransform on the image, I am now not being able to use the kinect zoom gesture. I guess it is due to assigning new LayoutTransform.

So instead of new System.Windows.Media.MatrixTransform(m); I would like something like navigationImage.LayoutTransform.SetValue(ScaleTransform.ScaleXProperty, Z / m.M11); but this gives me an error"Cannot set a property on object 'Identity' because it is in a read-only state."  So my question is how to set new value to layoutTransform.

Wpf Data validation on button

$
0
0

Hello,

I would like to use error template only when i push a button.

I'm trying the following code :

<TextBox Name="CLTDesc" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="2" Width="251" Margin="0 0 0 5" Text="{Binding CmdLnTmp.Description, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" GotFocus="TextBox_GFClear"></TextBox><TextBox Name="CLTPU"  HorizontalAlignment="Left" Grid.Row="2" Grid.Column="3" Width="90" Margin="0 0 0 5" Text="{Binding CmdLnTmp.PrixUnitaire, Converter={StaticResource StringToDoubleConverterN3Key}}" GotFocus="TextBox_GFClear" HorizontalContentAlignment="Right"></TextBox><TextBox Name="CLTQte"  HorizontalAlignment="Left" Grid.Row="2" Grid.Column="4" Width="90" Margin="0 0 0 5" Text="{Binding CmdLnTmp.Quantite, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" GotFocus="TextBox_GFClear" HorizontalContentAlignment="Center"></TextBox><TextBox Grid.Row="2"  HorizontalAlignment="Left" Grid.Column="5" Width="90" Margin="0 0 0 5" IsReadOnly="True" Language="FR-fr" Text="{Binding CmdLnTmp.Total_HT,StringFormat={}\{0:N3\},Mode=OneWay}" HorizontalContentAlignment="Right"></TextBox><Button Grid.Column="6" Grid.Row="2" Width="60" HorizontalAlignment="Left" Margin="5 0 0 5" Command="{Binding AddLine}" Content="Ajouter" Click="Add_Click" Style="{StaticResource FlatButton}" BorderBrush="White" Background="#FF365F91" Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>

with this template :

<Grid.Resources><Style TargetType="TextBox"><Style.Triggers><Trigger Property="Validation.HasError" Value="true"><Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" /></Trigger></Style.Triggers></Style><Style TargetType="ComboBox"><Style.Triggers><Trigger Property="Validation.HasError" Value="true"><Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/><Setter Property="Control.BorderBrush" Value="Red" /></Trigger></Style.Triggers></Style></Grid.Resources>

My problem is the OnChangedProperty (i think) because i would like to have the red borders draw after push my button.

At the moment when i load the GUI my textbox are already in red and when i change the content.

Anyone have an idea to get the validation only on the button ? (I'm beginner)


Datagrid Cell Format

$
0
0

Can somebody please help me out (In WPF for absolute DUMMIES fashion) how I can achieve the following:

I have a DataGrid that I add market data to under the following column Headings:

Updated, Volume, Price

I want to format the volume cell whenever the volume value in that cell is 1) between certain values and 2) Greater than a certain value (Similar to conditional formatting of cells in Excel).

I have tried this:

<DataGridTextColumn.ElementStyle>
                        <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                                <Trigger Property="Text" Value="10">
                                    <Setter Property="Background" Value="LightGreen"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>

But the problem is I need to use 'BETWEEN' and 'GREATER THAN', and as you can see, the Value is '=10'

I have gone through many solutions people have posted using IValueConverterbut I keep getting errors that I can't seem to resolve. Can someone please provide a walkthrough, or a link to a walkthrough in REAL MONKEY STUPID SIMPLE fashion for someone trying to learn WPF. Thank you!

WPF crashing by Environment.FailFast

$
0
0

Hi,

I am working on WPF application built for Kiosk (Touch Screen). We build Virtual Keyboard for ourselves.

There is one screen we list some items (max of 4 items) using DataGrid control which has a TextBox. The virtual keyboard shows on focus (thats how it built).

When we make selecting different items randomly, the application crashes without reaching the generic exception handler. This issue is repeatable on Touch screen, but not in regular screens. The event log shows the below,

Application: CashNGo.WPF.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string
message).
Message: Unrecoverable system error.
Stack:   at System.Environment.FailFast(System.String)   at MS.Internal.Invariant.FailFast(System.String, System.String)   at MS.Internal.Invariant.Assert(Boolean, System.String)   at System.Windows.Documents.TextStore.VerifyTextStoreConsistency()   at System.Windows.Documents.TextStore.GrantLock()   at System.Windows.Documents.TextStore.GrantLockWorker(LockFlags)   at System.Windows.Documents.TextStore.RequestLock(LockFlags, Int32 ByRef)   at MS.Win32.UnsafeNativeMethods+ITextStoreACPSink.OnSelectionChange()   at System.Windows.Documents.TextStore.OnSelectionChanged()   at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextRange.NotifyChanged(Boolean,
Boolean)   at System.Windows.Documents.TextRangeBase.EndChange(System.Windows.Documents.ITextRange,
Boolean, Boolean)   at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextRange.Select(System.Windows.Documents.ITextPointer,
System.Windows.Documents.ITextPointer)   at System.Windows.Controls.TextBox.Select(Int32, Int32)   at System.Windows.Controls.TextBox.set_CaretIndex(Int32)   at Common.Controls.SoftKeyboard.<.cctor>b__1c(System.Windows.Controls.TextBox)   at System.Windows.Input.DelegateCommand`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]].Execute(System.__Canon)   at Common.Controls.SoftKeyboard+<>c__DisplayClass5.<SoftKeyboardFocus_Changed>b__0()   at System.Windows.Threading.Dispatcher.Invoke(System.Action, System.Windows.Threading.DispatcherPriority,
System.Threading.CancellationToken, System.TimeSpan)   at System.Windows.Threading.Dispatcher.Invoke(System.Action, System.Windows.Threading.DispatcherPriority)   at Common.Extensions+<>c__DisplayClass1.<DelayedInvoke>b__0(System.Object, System.EventArgs)   at System.Windows.Threading.DispatcherTimer.FireTick(System.Object)   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,
Int32)   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate,
System.Object, Int32, System.Delegate)  at System.Windows.Threading.DispatcherOperation.InvokeImpl()   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback,
System.Object, Boolean)   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback,
System.Object, Boolean)   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback,
System.Object)   at System.Windows.Threading.DispatcherOperation.Invoke()   at System.Windows.Threading.Dispatcher.ProcessQueue()   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean
ByRef)   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object,
Int32)   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate,
System.Object, Int32, System.Delegate)   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority,
System.TimeSpan, System.Delegate, System.Object, Int32)   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)   at System.Windows.Threading.Dispatcher.Run()   at System.Windows.Application.RunDispatcher(System.Object)   at System.Windows.Application.RunInternal(System.Windows.Window)   at System.Windows.Application.Run(System.Windows.Window)   at System.Windows.Application.Run()   at CashNGo.WPF.App.Main()

I did some search and found http://social.msdn.microsoft.com/Forums/vstudio/en-US/dfbd2526-8953-4ce8-97c2-43246fd251c0/wpf-framework-crashing-on-setting-foxus-in-textbox?forum=wpf which is exactly the same exception.

Any suggestion would be helpful.

Thanks.


Castle Rider
In the jungle the mighty jungle
The lion sleeps tonight...

Assign a style to dynamically generated ListBoxItem.

$
0
0

Hi,

I have a listbox which gets filled up dynamically:

 foreach (FileInfo f in myfiles)
            {
                Console.WriteLine(f.Name);
                MyList.Items.Add(f.Name);


            }

I want to assign a style to these dynamically generated listboxitems.

<ListBoxItem.RenderTransform><ScaleTransform x:Name="Transform1" ScaleX="0.98" ScaleY="1.02"/></ListBoxItem.RenderTransform><ListBoxItem.Triggers><EventTrigger   RoutedEvent="Button.MouseEnter"><BeginStoryboard ><Storyboard   ><DoubleAnimation Storyboard.TargetName="Transform1"
                                         Storyboard.TargetProperty="ScaleX"
                                         From="1" To="1.2" Duration="0:0:0"
                                          /></Storyboard></BeginStoryboard></EventTrigger></ListBoxItem.Triggers>

Can someone tell me how to apply this style to the listbox?

Thanks,

Shaleen 


TheHexLord


rendering custom adorner after zooming

$
0
0

I've developed a custom adorner that adorns a Canvas control.  The canvas contains a custom object (actually a line segment).  The adorner is simply a circle 10 pixels in diameter that is placed on top of the line segment.  The adorner's OnRender function draws this circle using the capabilities provided by the DrawingContext parameter.  When the canvas is zoomed, I make the following calculation at the beginning of OnRender:

ScaleTransform scaleTransform = new ScaleTransform();

scaleTransform.ScaleX = 1.0 / ZoomScaleFactor;

scaleTransform.ScaleY = 1.0 / ZoomScaleFactor;

drawingContext.PushTransform(scaleTransform);

... draw the circle then

drawingContext.Pop();

where ZoomScaleFactor is the new zoom scale factor for the canvas.  Due to the transform, the circle adorner remains the same size in spite of the zoom.  This is the desired result.  My problem is that the circle no longer lies on the line segment.  That is, the zoom operation has changed the position of the line segment but not the circle.  How can I maintain circle position relative to the line segment?

Thanks

dmm

 

          

 

IValueConverter variable

$
0
0

I use the following code in an IValueConverter. The problem is that the filter values are hardcoded and I want to be able to be changed by the user. How can I achieve this without resorting to reading from a file? It would be nice to have a textbox but I can't find a way of doing this. Can anyone help?

classBlockFilter:IValueConverter


    {

       

publicobjectConvert(objectvalue,TypetargetType,objectparameter, System.Globalization.CultureInfoculture)

        {

           

intfilter1 = 250

           

intfilter2 = 500;

           

intfilter3 = 1000;

           

doubletickSize = System.Convert.ToDouble(value);

           

if(tickSize == 0)

               

return0;

           

elseif((tickSize>= filter1) & (tickSize < filter2))

               

return250;

           

elseif((tickSize>= filter2) & (tickSize < filter3))

               

return500;

           

elseif((tickSize>= filter3))

               

return1000;

           

else


               

returnnull;

        }

       

publicobjectConvertBack(objectvalue,TypetargetType,objectparameter, System.Globalization.CultureInfoculture)

        {

           

thrownewNotImplementedException();

        }

    }

declaring a CollectionView from an ACCDB

$
0
0

In declaring a CollectionView in C# to interact with WPF, the following format is used:

CollectionView collViewName = (CollectionView)

     CollectionViewSource.GetDefaultView(rootElem.DataContext);

If the data file is an XML file, it's easy to see what would be called the root element.

Where would I find what needs to be used as the parameter for the CollectionViewSource.GetDefaultView statement if the source is an ACCDB query?

CollectionView RootElement for ACCDB

$
0
0
What would be considered the root element (for a CollectionView) of an ACCDB query?

Create a Behavior for Calendar in a WPF UserControl to Select and Unselect dates with one click

$
0
0

Hi to everyone,

I am developing an application with a WPF Client. This Client use the MVVM pattern.

In an UserControl the application must show some Calendars, so the user can select one or multiple dates.

For that use, I should implement some behavior that allows the user click once in a date and that date is selected (what already exists in .NET Framework) and with another click in the same date, that date is now unselected.

I've already made some searches and can't find anything useful.

This kind of behavior it is possible to implement in the Calendar Control? How exactly I do this?

Thanks for reading/helping


Rafael Duarte

Viewing all 18858 articles
Browse latest View live


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