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

wpf saving data to database

$
0
0

Hi,

I want to save tree view data to dataset and then make xml so that i may save to my table .please help...


DataGrid ComboBox DataBinding!?

$
0
0

Hi!

I am searching a lot of hours for my Problem to fix it!?

Here is my XML Code:

<DataGridTemplateColumn Header="Spalte6" MinWidth="10" CanUserSort="True" x:Name="SP006"><DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Name="SP006" Text="{Binding GrSpalte06}" AcceptsReturn="True" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" MaxLength="26" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEditingTemplate><DataTemplate><ComboBox 
                                        SelectedValuePath="Mitarbeiter" 
                                        SelectedValue="{Binding Mitarbeiter}" 
                                        DisplayMemberPath="Mitarbeiter" 
                                        ItemsSource="{Binding Path=MitarbeiterZeilen, Mode=TwoWay}"
                                        SelectedItem="{Binding Path=GrSpalte06, Mode=TwoWay}"
                                        IsReadOnly="True" Background="White"                                    
                                    /></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn>

I will bind the ComboBox on this List:

    public class WPFMitarbeiterZeilen
    {
        public string MitarbeiterZeile { get; set; }
    }

But it will not working?

The Target if the selection is Change is "SP006"...

Where is the mistake?

Best Regards

Bernd

Exceptions: 0xC0020001 and 0xC000041D

$
0
0

Hello,
I am getting a crash when my application exits. It's a big application mixing C#, C++ managed, C++and two UI technologies WPF and MFC. 
It happens after the  System.Windows.Application.Exit Event and there is nothing related to my code in the call stack (see below).
In Visual studio output, I have only the following lines (Before there's only thread exit messages)
First-chance exception at 0x757fb9bc (KernelBase.dll) in Editor.exe: 0xC0020001: The string binding is invalid.
Unhandled exception at 0x757fb9bc (KernelBase.dll) in Editor.exe: 0xC000041D: An unhandled exception was encountered during a user callback.

Call stack:

    KernelBase.dll!_RaiseException@16()  + 0x58 bytes	
    clr.dll!COMPlusThrowBoot()  + 0x1e bytes	
    clr.dll!_UMThunkStubRareDisableWorker@12()  + 0x27 bytes	
    clr.dll!_UMThunkStubRareDisable()  + 0xa bytes	
    user32.dll!_DispatchHookW@16()  + 0x38 bytes	
    user32.dll!_CallHookWithSEH@16()  + 0x21 bytes	
    user32.dll!___fnHkINDWORD@4()  + 0x28 bytes	
    ntdll.dll!_KiUserCallbackDispatcher@12()  + 0x2e bytes	
    user32.dll!_NtUserDestroyWindow@4()  + 0x15 bytes	
    msctf.dll!SYSTHREAD::DestroyMarshalWindow()  + 0x263 bytes	
    msctf.dll!TF_UninitThreadSystem()  + 0x5c bytes	
    msctf.dll!CicFlsCallback()  + 0x29 bytes	
    ntdll.dll!_RtlProcessFlsData@4()  + 0xea bytes	
    ntdll.dll!_LdrShutdownProcess@0()  + 0x97 bytes	
    ntdll.dll!_RtlExitUserProcess@4()  + 0x74 bytes	
    kernel32.dll!76e97383() 	
    mscoreei.dll!RuntimeDesc::ShutdownAllActiveRuntimes()  + 0xc8 bytes	
    mscoreei.dll!CLRRuntimeHostInternalImpl::ShutdownAllRuntimesThenExit()  + 0x15 bytes	
    clr.dll!EEPolicy::ExitProcessViaShim()  + 0x66 bytes	
    clr.dll!SafeExitProcess()  + 0x99 bytes	
    clr.dll!DisableRuntime()  - 0x16dab3 bytes	
    clr.dll!EEPolicy::HandleExitProcess()  + 0x57 bytes	
    clr.dll!__CorExeMainInternal@0()  + 0x11c bytes	
    clr.dll!__CorExeMain@0()  + 0x1c bytes	
    mscoreei.dll!__CorExeMain@0()  + 0x38 bytes	
    mscoree.dll!_ShellShim__CorExeMain@0()  + 0x227 bytes	
    mscoree.dll!__CorExeMain_Exported@0()  + 0x8 bytes	
    kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes	
    ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes	
    ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes	

I saw many posts about the exception 0xC000041D but nothing really useful for me.
Does anyone know a way to have more information or does anyone have encountered the same issue? 

Thank you.

Data binding SplineDoubleKeyFrame.Value doesn't work first time when it triggered from code behind

$
0
0

I want to control SplineDoubleKeyFrame.Value from code behind, so I used data binding with my ViewModel class. But, it doen't work as expected.

MainWindow.xaml:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Name="Root"><Window.Resources><Storyboard x:Key="MyStory"><DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                           Storyboard.TargetName="Root"
                                           Storyboard.TargetProperty="Height"><SplineDoubleKeyFrame KeyTime="00:00:00" Value="100"/><SplineDoubleKeyFrame KeyTime="00:00:00.500" Value="{Binding ToValue}"/></DoubleAnimationUsingKeyFrames></Storyboard></Window.Resources><Grid><Button Content="Click me" Click="Button_Click"/></Grid></Window>

MainWindow.xaml.cs

using System.Windows;
using System.Windows.Media.Animation;

namespace WpfApplication1
{
    public partial class MainWindow : Window
    {
        class MyViewModel
        {
            public double ToValue
            {
                get { return 300; }
            }
        }

        public MainWindow()
        {
            InitializeComponent();
            DataContext = new MyViewModel();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Storyboard story = (Storyboard)FindResource("MyStory");
            story.Begin(this);
        }
    }
}

Expected results:

When I click the button, window height should animate from 100 to 300.

Actual results:

For the first click, window height change from 100 to 0.

Next click, window height animate from 100 to 300 (expected)

Note:

When I use EventTrigger, it works as expected.

<Button Content="Click me"><Button.Triggers><EventTrigger RoutedEvent="Button.Click"><BeginStoryboard Storyboard="{StaticResource MyStory}"/></EventTrigger></Button.Triggers></Button>

What it the deference between code behind (Storyboard.Begin()) and XAML (BeginStoryboard)?

Environment:

  • Visual Studio 2013
  • .NET 4.5.1 / 3.5

WPF xbap failes when access through https

$
0
0

Dear,

When i deploy WPF browser application on server, i am unable to access through https. but it works well with HTTP,

Below is the error when i access from HTTPS

Security certificate required to access this resource is invalid.

Application is running on Full trust but it is not signed. I am not selected the option "Sign the clickOnce manifest". and removed the default key which created at the time of project creation.

Server has already been installed with a certificate which is on server host name. I donot have any clue why the this error throwing when access throug HTTP

the url iam trying to access is https://webxbap2.testuat.com/test/test.xbap but the certifate name is wdctmst2u

please let me know how can i access xbap through https and what steps to be followed

Expecting a reply ASAP 

C# WPF Alternate to WinForms .Show();

$
0
0

Hi,

I'm new to Visual C#, I am looking for a way to display a window in WPF as .Show and .ShowDialog seem to only work in WinForms.

Thanks in advance

Drag Drop hierarchical treeview

$
0
0

Hi 

need your help on this 

I use this sample code to Drag and Drop in my application (WPF)

XAML

<TreeView Name="trvFamilies" AllowDrop="True" Background="PowderBlue" Foreground="DarkBlue" FontSize="15"><TreeViewItem Header="1" ><TreeViewItem Header="1.1" ><TreeViewItem Header="1.1.1" ></TreeViewItem></TreeViewItem></TreeViewItem><TreeViewItem Header="2" ><TreeViewItem Header="2.1" ><TreeViewItem Header="2.1.1" ><TreeViewItem Header="2.1.1.1" ><TreeViewItem Header="2.1.1.1.1" ></TreeViewItem></TreeViewItem></TreeViewItem></TreeViewItem><TreeViewItem Header="2.2" ><TreeViewItem Header="2.2.1" AllowDrop="True"></TreeViewItem></TreeViewItem></TreeViewItem><TreeView.ItemContainerStyle><Style TargetType="{x:Type TreeViewItem}"><EventSetter Event="TreeViewItem.DragOver" Handler="treeView_DragOver"/><EventSetter Event="TreeViewItem.Drop" Handler="treeView_Drop"/><EventSetter Event="TreeViewItem.MouseMove" Handler="treeView_MouseMove"/></Style></TreeView.ItemContainerStyle></TreeView>

C#

  Point _lastMouseDown;
        TreeViewItem draggedItem, _target;
        private void treeView_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                _lastMouseDown = e.GetPosition(trvFamilies);
            }
        }
        private void treeView_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    Point currentPosition = e.GetPosition(trvFamilies);

                    if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) ||
                        (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0))
                    {
                        draggedItem = (TreeViewItem)trvFamilies.SelectedItem;
                        if (draggedItem != null)
                        {
                            DragDropEffects finalDropEffect =
                DragDrop.DoDragDrop(trvFamilies,
                    trvFamilies.SelectedValue,
                                DragDropEffects.Move);
                            //Checking target is not null and item is 
                            //dragging(moving)
                            if ((finalDropEffect == DragDropEffects.Move) &&
                    (_target != null))
                            {
                                // A Move drop was accepted
                                if (!draggedItem.Header.ToString().Equals
                    (_target.Header.ToString()))
                                {
                                    CopyItem(draggedItem, _target);
                                    _target = null;
                                    draggedItem = null;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }

        private void treeView_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                Point currentPosition = e.GetPosition(trvFamilies);

                if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) ||
                   (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0))
                {
                    // Verify that this is a valid drop and then store the drop target
                    TreeViewItem item = GetNearestContainer
                    (e.OriginalSource as UIElement);
                    if (CheckDropTarget(draggedItem, item))
                    {
                        e.Effects = DragDropEffects.Move;
                    }
                    else
                    {
                        e.Effects = DragDropEffects.None;
                    }
                }
                e.Handled = true;
            }
            catch (Exception)
            {
            }
        }
        private void treeView_Drop(object sender, DragEventArgs e)
        {
            try
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;

                // Verify that this is a valid drop and then store the drop target
                TreeViewItem TargetItem = GetNearestContainer
                    (e.OriginalSource as UIElement);
                if (TargetItem != null && draggedItem != null)
                {
                    _target = TargetItem;
                    e.Effects = DragDropEffects.Move;
                }
            }
            catch (Exception)
            {
            }
        }

        private bool CheckDropTarget(TreeViewItem _sourceItem, TreeViewItem _targetItem)
        {
            //Check whether the target item is meeting your condition
            bool _isEqual = false;
            if (!_sourceItem.Header.ToString().Equals(_targetItem.Header.ToString()))
            {
                _isEqual = true;
            }
            return _isEqual;

        }
        private void CopyItem(TreeViewItem _sourceItem, TreeViewItem _targetItem)
        {

            //Asking user wether he want to drop the dragged TreeViewItem here or not
            if (MessageBox.Show("Would you like to drop " + _sourceItem.Header.ToString() + " into " + _targetItem.Header.ToString() + "", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                try
                {
                    //adding dragged TreeViewItem in target TreeViewItem
                    addChild(_sourceItem, _targetItem);

                    //finding Parent TreeViewItem of dragged TreeViewItem 
                    TreeViewItem ParentItem = FindVisualParent<TreeViewItem>(_sourceItem);
                    // if parent is null then remove from TreeView else remove from Parent TreeViewItem
                    if (ParentItem == null)
                    {
                        trvFamilies.Items.Remove(_sourceItem);
                    }
                    else
                    {
                        ParentItem.Items.Remove(_sourceItem);
                    }
                }
                catch
                {

                }
            }

        }
        public void addChild(TreeViewItem _sourceItem, TreeViewItem _targetItem)
        {
            // add item in target TreeViewItem 
            TreeViewItem item1 = new TreeViewItem();
            item1.Header = _sourceItem.Header;
            _targetItem.Items.Add(item1);
            foreach (TreeViewItem item in _sourceItem.Items)
            {
                addChild(item, item1);
            }
        }
        static TObject FindVisualParent<TObject>(UIElement child) where TObject : UIElement
        {
            if (child == null)
            {
                return null;
            }

            UIElement parent = VisualTreeHelper.GetParent(child) as UIElement;

            while (parent != null)
            {
                TObject found = parent as TObject;
                if (found != null)
                {
                    return found;
                }
                else
                {
                    parent = VisualTreeHelper.GetParent(parent) as UIElement;
                }
            }

            return null;
        }
        private TreeViewItem GetNearestContainer(UIElement element)
        {
            // Walk up the element tree to the nearest tree view item.
            TreeViewItem container = element as TreeViewItem;
            while ((container == null) && (element != null))
            {
                element = VisualTreeHelper.GetParent(element) as UIElement;
                container = element as TreeViewItem;
            }
            return container;
        }

It works like I want but when I try to change it with my Treeview (hierarchical data template). it no longer works.

<TreeView HorizontalAlignment="Left" ItemsSource="{Binding MyData}" x:Name="trvFamilies" Background="{x:Null}" Margin="0,42,0,0" Width="243" Padding="0" BorderThickness="0" >

<TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                   
                    <EventSetter Event="TreeViewItem.DragOver" Handler="treeView_DragOver"/>
                    <EventSetter Event="TreeViewItem.Drop" Handler="treeView_Drop"/>
                    <EventSetter Event="TreeViewItem.MouseMove" Handler="treeView_MouseMove"/>




                </Style>

            </TreeView.ItemContainerStyle>

<TreeView.Resources><HierarchicalDataTemplate DataType="{x:Type local:Family}" ItemsSource="{Binding Children}"><StackPanel Orientation="Horizontal"><Image Source="{Binding myImg }" Margin="5,0,5,0" Height="18" Width="18" > </Image><TextBlock Text="{Binding Path=myName}" Width="167" Padding="0,3,0,0" TextTrimming="CharacterEllipsis" > </TextBlock><Label Content="{Binding myAge}" Foreground="#FF515151" Width="39" HorizontalContentAlignment="Right" Margin="0,0,12,0"> </Label></StackPanel></HierarchicalDataTemplate><DataTemplate DataType="{x:Type local:FamilyMember}" ><StackPanel Orientation="Horizontal"><Image Source="{Binding Img}" Margin="21,0,5,0" Height="18" Width="18" /><TextBlock x:Name="surl" Text="{Binding Name}" Width="158" TextTrimming="CharacterEllipsis" Padding="0,3,0,0" /><Label Content="{Binding Age}" Foreground="#FF515151" Width="30" HorizontalContentAlignment="Right" Margin="0,0,12,0"/></StackPanel></DataTemplate></TreeView.Resources></TreeView>


public ObservableCollection<Family> MyData { get; set; }
  public HomePage()
        {
            InitializeComponent();
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(System.IO.Directory.GetCurrentDirectory() + "//FamilyBook.xml");
             XmlNodeList nodeName = xmlDoc.GetElementsByTagName("Name");
            XmlNodeList nodeGender = xmlDoc.GetElementsByTagName("Gender");
            XmlNodeList nodeAge = xmlDoc.GetElementsByTagName("Age");
            XmlNodeList nodeImg = xmlDoc.GetElementsByTagName("Icon");
            XmlNodeList elemList = xmlDoc.GetElementsByTagName("item");
            MyData = new ObservableCollection<Family>();
            for (int i=0; i < elemList.Count; i++)
            {
                MyData.Add(new Family()
                {
				    myName = nodeName[i].InnerText,
                    myGender = nodeGender[i].InnerText,
                    myAge= Convert.ToInt32(nodeAge[i].InnerText),
                    myImg = System.IO.Directory.GetCurrentDirectory() + "/favicon/" + nodeImg[i].InnerText 
                });
            }   

        }


public class Family : INotifyPropertyChanged
    {
        public Family()
        {
            this.Children = new ObservableCollection<FamilyMember>();
        }
        private int _myage;

        public int myAge
        {
            get { return _myage; }
            set
            {
                if (_myage != value)
                {
                    _myage = value;
                    OnPropertyChanged("Age");
                }
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;


        protected void OnPropertyChanged(string p_strPropertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(p_strPropertyName));
        }
        public string myName { get; set; }
        public string myGender { get; set; }
		 public string myImg { get; set; }
       
        public ObservableCollection<FamilyMember> Children { get; set; }
    }
	public class FamilyMember
    {
        public string Name { get; set; }

        public string Age { get; set; }
        public string Img { get; set; }

       

    }

I recovered the  selected treeview item  with this code.

TreeViewItem tvi = sender as TreeViewItem;
if (tvi != null)
                {
Family root = tvi.DataContext as Family;
if (root != null)
                    {
					  string name;
                         name = root.myName;
					}
}
Thanks for your help 

problem in serialize a class that Implements INotifyPropertyChanged

$
0
0

Hello

 

I have a class used to store some data.

To be able to bind this class to a control i have to implement the

INotifyPropertyChanged  but if I implement it  i can not serialize the class any more

Type 'System.ComponentModel.PropertyChangedEventManager' in Assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable

 

How can I overcome this problem?


display previous value of TextBox/ComboBox

$
0
0

I need to display previous value of TextBox/ComboBox via label under it and a restore button.

I think of inheriting from TextBox/ComboBox with changing of their templates

or creating a UserControl with reference to the TextBox/ComboBox.

Each approach has drawbacks - styling complexity in 1st and additional typing in 2nd.

Is there a better way?

Thanks, Dan

Problems setting MediaPlayer.Position for long videos

$
0
0

Hi,

I am using the WPF mediaplayer to play video. I set player.ScrubbingEnabled to true, and set
player.Position to a particular time to jump around in the video, displaying the frame closest
to the selected position. All works well for shorter videos. However for videos in excess of
30 minutes, the real video position does not get set correctly - the frame that gets
displayed does not correspond to the time set, it is typically for a position a few seconds before
the specified time. If I call player.Play() and then poll the Position value frequently, I can see that the
player.Position value will initially show the set position, but once the video starts to play, the time
jumps backwards a few seconds, before starting to move forward as expected. 

Does anyone know if there is a work around to this. It's important for my application that the frame displayed
when the Position is set, corresponds to that position, and not just to the nearest keyframe - which I suspect
is what is happening. Like I said, for <30 minute video, this is not the case, and the videoplayer seeks to the
nearest frame. 

Thanks

Chris

set checkbox in a combox to checked wpf

$
0
0

Hi,

I have created a custom wpf control- essentially a combox with checkbox. The combox all successfully bound to a list of item.

It's my xaml code.

    <ComboBox Height="28" HorizontalAlignment="Left" Margin="106,7,0,0" Name="comboBox1" VerticalAlignment="Top" Width="174" ItemsSource="{Binding Names}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Name="ckabc" Content="{Binding}" CommandParameter="{Binding}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox> 

My code is here like this:

    private List<string> names;
    public List<string> Names
        {
            get { return names; }
            set
            {
                names = value;
                this.OnPropertyChanged(new PropertyChangedEventArgs("Names"));
            }
        }
    Names = new List<string> { "Sensor Not Connected", "Poor Signal Quality", "Excessive Light", "PreAmp Not Connected", "Replace Sensor", "Interference Detected", "Sensor Unusable","Sensor Change" };
            this.OnPropertyChanged(new PropertyChangedEventArgs("Names"));

I have created property for each list item:

    public string SensorNotConnected
        {
            get
            {
                return Names.ElementAt(0);
            }
            set
            {
                this.emuObj.SensorNotConnected(Convert.ToBoolean(value), channelIndex);
            }
        }
same way created property for other list item.
My thinking is to bind Ischecked property of checkbox and iterate over.
But how Can I do that. User can select one check box or multiple checkbox.
Please provide some answer for this.

P.S: I'm using MVVM model.


vikas sharma AB


Thread issue with OvservableCollection

$
0
0

Dear all, 

The whole point of OvservableCollection, I guess, is that logic could be separated from UI. 

But it seems that I cannot modify an OvservableCollection in any thread other thanthe UI thread. 

If I have to do that, I need to do it in an asynchronous call, with a reference to a UI component or context. This obviously mix the logic with the UI.

I found on the web a lot of complains and hacking on  the OvservableCollection. When is MS gonna take care of this issue ?

WPF + Bluetooth + COnected object

$
0
0

Dear all,

I need to build a proof of concept of a WPF application and mobile application by using the Bluethooth Low energy technologie to collect different type of information from a device which is able to send such information. We are talking a lot on connected object today and I think as far as I know their use such technologies.

How can I start to build such application ?

Is there some dev kit or such thing ?

Any sample already around ?

Thnaks for tips and advise

regards

serge


Your knowledge is enhanced by that of others.

Sap Crystal Report Max Print Exception

$
0
0
In Sap Crystal Report after 60 to 70 reports print report doesn't show. When I set registry value of PrintJobLimit from c# code then exception fire "User can't authorize or permit for edit".

about the multi-touch in WPF

$
0
0

what's the foundation of the multi-touch in wpf,

in other words,I want to know how to accomplish the manipulation without manipulationstarting,manipulationdelta,etc.

I know single-touch can be accomplished with touchdown,touchmove,touchup.etc,

but things seem to be complicated when it comes to multi-touch.


about the multi-touch in WPF

$
0
0

what's the foundation of the multi-touch in wpf,

in other words,I want to know how to accomplish the manipulation without manipulationstarting,manipulationdelta,etc.

I know single-touch can be accomplished with touchdown,touchmove,touchup.etc,

but things seem to be complicated when it comes to multi-touch.

Getting the text of the selected item in the combobox in WPF

$
0
0

Hi,

 

I am facing issues regarding "getting the text of the selected item in the combobox"

i have tried something but it doesn't work.

1. This is my code on Page1.xaml

<Pagex:Class="test.Page1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="Page1"

>

<

Grid>

<

ComboBoxHeight="26"Margin="87,96,104,0"Name="comboBox1"VerticalAlignment="Top">

<

ComboBoxItemSelected="combobox1_Changed">1</ComboBoxItem>

<

ComboBoxItemSelected="combobox1_Changed">2</ComboBoxItem>

</

ComboBox>

</

Grid>

</

Page>

 

and this is Page1.xaml.cs

 

void combobox1_Changed(object sender, RoutedEventArgs e)

{

ComboBoxItem cbi = (ComboBoxItem)comboBox1.SelectedItem;

MessageBox.Show(cbi.ToString());

}

 

after selecting the combobox item the event fires but i don't get any value for SelectedValue, SelectedItem, Text etc..

The values are always null.

Why is it so?

 

2. I also tried it using DependencyPropertyDescriptor

 

This is the code

(The Page1.xaml is same as above)

 

code behind is:-

public

partialclassPage1 : System.Windows.Controls.Page

{

DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(ComboBox.TextProperty, typeof(ComboBox));

publicPage1()

{

InitializeComponent();

}

privatevoidfunc()

{

dpd.AddValueChanged(comboBox1, combobox1_Changed);

MessageBox.Show(comboBox1.Text);

}

voidcombobox1_Changed(objectsender, RoutedEventArgs e)

{

func();

}

}

 

But in this case highlighted red line gives me an error as "Argument 2 can not converrt from 'method group' to 'system.eventhandler'"

 

Can anybody please sort this issue. It's urgent...

 


Regards,

Amit Gadre.

How to move the mouse on the tooltip which contain a linkbutton, I want to click it.

$
0
0

Hi all,

An sample code as below, I want to click a linkbutton in tooltip. But when I move mouse out the button  control, then the tooltip has been disappeared. How do I implement it?

Actually, I want to implement a thing like office 2013 Ribbon. The ribbon button tooltip has a link (tell me more or help, and so on), thanks.

<Button Content="Tooltip" Height="100" Margin="60">
   <Button.ToolTip>
    <ToolTip Placement="Bottom">
     <StackPanel>
      <TextBlock FontWeight="Heavy">Two TextBlock</TextBlock>
      <TextBlock>this is Tooltip</TextBlock>
     </StackPanel>
    </ToolTip>
   </Button.ToolTip>
  </Button>

Styles and Data Binding Errors!

$
0
0

Hi Everyone,

I have a rather general question.

How to get rid of run time Data Binding errors, which occur due to global styles?

Let me explain...

I have a style like this:

<Style x:Key="ContextMenuItemStyle"
           BasedOn="{StaticResource ContextMenuItemStyle}"
           TargetType="{x:Type MenuItem}"><Setter Property="Header"
                Value="{Binding Header}" /><Setter Property="Command"
                Value="{Binding Command, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /><Style.Triggers><DataTrigger Binding="{Binding}"
                         Value="{x:Null}"><Setter Property="Template"><Setter.Value><ControlTemplate><Separator /></ControlTemplate></Setter.Value></Setter></DataTrigger></Style.Triggers></Style>

Of course there are a couple of things more in the style, which are not mentioned here.

Now, this style is used is almost 20 plus views in the application.

Due to the binding I have in this style, when I run the application, in the Output window I get Data Binding not found errors. 

I am thinking such behavior slows down the application?

How can I keep this style in one location globally and get rid of these errors?


Please Mark as Answered If this answers your question OrUnMark as Answered if it did not.
Happy to Help :)
My Site

Sample projects for MVVM Light

$
0
0

Hi,

I've created a project in VS 2012 with MVVM Light(4.5) template.  It comes with few classes and folders.  I was wondering if there are any sample codes or examples on how to customise it for basic needs.

I am struggling to understand ViewModelLocator class, ServiceLocator and SimpleIoc.  I've searched online and understand that the locator is a singleton instance for an entire application and a repository for all viewModels. 

I don't understand do I need to create properties in this class for each viewModel or how does it work ?  Are there any simple but real word examples  - I am just failing to grasp the basics of MVVM Light and it's template.

thanks

Viewing all 18858 articles
Browse latest View live


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