CanExecute command carries out update instead of Execute command - wpf

I have created methods in C# visual studio 2010 that disable or enable buttons in a record using wpf commands as below:
private void CanSavePageCommandExecute(object sender, CanExecuteRoutedEventArgs e)
{
**if (studentsViewSource != null && studentsViewSource.View != null && novelDataSetTableAdapter.Update(novelDataSet.students) > 0)
{
e.CanExecute = true;
//e.Handled = true;
}
else
{
e.CanExecute = false;
}
}**
should be:
private void CanSavePageCommandExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = studentsViewSource != null && this.novelDataSet.HasChanges();
e.Handled = true;
}
private void OnSavePageCommandExecute(object sender, ExecutedRoutedEventArgs e)
{
if (novelDataSetTableAdapter.Update(novelDataSet.students) > 0)
MessageBox.Show("Entries have been updated !", "DATA STATUS");
else
MessageBox.Show("Error occurred!", "DATA NOT SAVED");
}
The 'CanSavePageCommandExecute' is supposed to just disable the SAVE button if the enclosed conditions are met. It actually does that but it goes a step further and saves the data to the database.
The 'OnSavePageCommandExecute' command is not carried out even if I just test using MessageBox.show.
How do I prevent the CanExecute command from saving data to just enabling and disabling button based on changes made to the datasets?
I am not using MVVM but this is part of the Xaml code from a user control:
<UserControl.CommandBindings>
<CommandBinding Command="New"
CanExecute="CanNewPageCommandExecute" Executed="OnNewPageCommandExecute" />
<CommandBinding Command="NavigationCommands.PreviousPage"
CanExecute="CanPreviousPageCommandExecute" Executed="OnPreviousPageCommandExecute" />
<CommandBinding Command="NavigationCommands.NextPage"
CanExecute="CanNextPageCommandExecute" Executed="OnNextPageCommandExecute" />
<CommandBinding Command="FirstPage"
CanExecute="CanPreviousPageCommandExecute" Executed="OnFirstPageCommandExecute" />
<CommandBinding Command="LastPage"
CanExecute="CanNextPageCommandExecute" Executed="OnLastPageCommandExecute" />
<CommandBinding Command="{x:Static local:student.saves}"
CanExecute="CanSavePageCommandExecute" Executed="OnSavePageCommandExecute" />
<CommandBinding Command="Delete"
CanExecute="CanDeletePageCommandExecute" Executed="OnDeletePageCommandExecute" />
</UserControl.CommandBindings>
<Border Width="Auto" Height="Auto" BorderThickness="1" CornerRadius="2">
<dxlc:LayoutControl Name="layoutControl1" Cursor="Arrow">
<dxlc:LayoutGroup Orientation="Vertical" Height="303">
<Border BorderThickness="1" Height="160" Width="160" BorderBrush="Black" Margin="0,0,0,20">
<Border.Background>
<ImageBrush ImageSource="/college12;component/images/prime.jpg" Stretch="Uniform" TileMode="None" />
</Border.Background>
<Image Height="150" Name="studypixx" Stretch="UniformToFill" Width="150" UseLayoutRounding="False" DataContext="{StaticResource studentsViewSource}" Source="{Binding Path=studyphoto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Border>
<Button Content="Upload Photo" Height="23" HorizontalAlignment="Center" Name="studentphotoupload" VerticalAlignment="Top" Width="116" ToolTip="Inserts photo" Background="#FFEC3B3B" BorderBrush="Black" Cursor="Hand" Click="studentphotoupload_Click" />
<TextBox Name="photo_text" Width="160" HorizontalAlignment="Left" Height="20" IsHitTestVisible="False" Visibility="Visible" Text="{Binding Path=studyphoto, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" DataContext="{StaticResource studentsViewSource}" />
<dxlc:LayoutGroup Name="layoutGroup3" View="GroupBox" Width="160" Height="62">
<Button Content="NEW STUDENT" Height="23" HorizontalAlignment="Center" Name="addstudent" VerticalAlignment="Bottom" Width="93" Command="ApplicationCommands.New" Cursor="Hand" />
</dxlc:LayoutGroup>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup Orientation="Vertical">
<dxlc:LayoutGroup Name="layoutGroup1" View="GroupBox" Height="238" UseLayoutRounding="True" Orientation="Vertical" Width="450" DragScrolling="False" Header="{Binding Path=surname}" DataContext="{StaticResource studentsViewSource}">
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="First Name" Name="layoutItem1">
<dxe:TextEdit Name="first_name" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" MaskSaveLiteral="True" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=firstname, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=LostFocus}" />
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Middle Name" Name="layoutItem2">
<dxe:TextEdit Name="other_name" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" MaskSaveLiteral="True" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=othername, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Surname" Name="layoutItem3">
<dxe:TextEdit Name="other_surname" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" MaskSaveLiteral="True" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=surname, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=LostFocus}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Email" Name="layoutItem10">
<dxe:TextEdit Name="email_address" EditValue="{Binding Path=email, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Birth Date" Name="layoutItem4">
<dxe:DateEdit Name="birth_date" Mask="d/MM/yyyy" MaskSaveLiteral="False" MaskType="DateTime" MaskUseAsDisplayFormat="True" UseLayoutRounding="False" FontFamily="Consolas" FontSize="12" EditValue="{Binding Path=birthdate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Enrol Date" Name="layoutItem5">
<dxe:DateEdit Name="enrol_date" MaskUseAsDisplayFormat="True" MaskType="DateTime" MaskSaveLiteral="False" Mask="d/MM/yyyy" UseLayoutRounding="False" FontFamily="Consolas" FontSize="12" EditValue="{Binding Path=enroldate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Enrol NO." Name="layoutItem6">
<dxe:TextEdit Name="enrol_no" FontFamily="Consolas" FontSize="10" EditValue="{Binding Path=enrolnum, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Phone NO." Name="layoutItem9">
<dxe:TextEdit Name="phone_no" Mask="(\d?\d?\d?\d)\d\d-\d\d-\d\d" MaskType="Regular" MaskUseAsDisplayFormat="True" FontFamily="Consolas" FontSize="10" MaskBeepOnError="False" MaskSaveLiteral="False" AcceptsReturn="True" AcceptsTab="True" EditValue="{Binding Path=phone, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Address" Name="layoutItem7">
<dxe:TextEdit Name="address" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" EditValue="{Binding Path=address, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Town/City" Name="layoutItem8">
<dxe:TextEdit Name="town_city" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=town, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup Name="layoutGroup2" View="GroupBox" Width="450">
<Button Content="FIRST" Height="23" HorizontalAlignment="Left" Name="firststudent" VerticalAlignment="Top" Width="75" Cursor="Hand" Command="NavigationCommands.FirstPage" />
<Button Content="PREVIOUS" Height="23" HorizontalAlignment="Left" Name="previoustudent" VerticalAlignment="Top" Width="75" Command="NavigationCommands.PreviousPage" ToolTip="Preceding student record" Cursor="Hand" />
<Button Content="NEXT" Height="23" HorizontalAlignment="Left" Name="nextstudent" VerticalAlignment="Top" Width="75" Command="NavigationCommands.NextPage" ToolTip="Next student record" Cursor="Hand" />
<Button Content="LAST" Height="23" HorizontalAlignment="Left" Name="laststudent" VerticalAlignment="Top" Width="75" Cursor="Hand" Command="NavigationCommands.LastPage" />
<Button Content="SAVE" Height="23" HorizontalAlignment="Left" Name="savestudent" VerticalAlignment="Top" Width="75" Cursor="Hand" Command="{x:Static local:student.saves}"/>
</dxlc:LayoutGroup>
</dxlc:LayoutGroup>
</dxlc:LayoutControl>
</Border>

Related

How to bind a Command to ItemsControl's template

I have to create an ItemsControl like below and a view model with a clickcommand. How can I bind the command to its template?
<ItemsControl Name="connStatusList" HorizontalAlignment="Left" VerticalAlignment="Top" Background="#e0e0e0" Margin="0,0,0,0" MinHeight="325" Width="1700" ItemsSource="{Binding }" >
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Border>
<ItemsPresenter/>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Name="wp" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal" Background="#ededed" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<WrapPanel Width="135" Height="160" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,1,0,0" >
<WrapPanel Background="{StaticResource connRectangle}" Width="133" Height="128">
<Image Source="{Binding WifiImage}" Width="70" Height="53" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,2,0,0"/>
<Image Source="{Binding ConnectedImage}" Width="43" Height="63" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="45,7,0,0" />
</WrapPanel>
<WrapPanel>
<Label Content="{Binding ItemNO}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="35,0,0,0" FontWeight="Bold" FontSize="18"></Label>
<Label Content="{Binding Connected}" Name="lblconnected" Visibility="Collapsed"></Label>
</WrapPanel>
</WrapPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
As you are essentially creating a list of buttons, use a Button in your template to bind the command. I assume your command property is called ClickCommand. You might need to adapt the style of the button e.g. in mouse-over state to fit your application.
<DataTemplate>
<Button Command="{Binding ClickCommand}">
<Button.Content>
<WrapPanel Width="135" Height="160" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,1,0,0" >
<WrapPanel Background="{StaticResource connRectangle}" Width="133" Height="128">
<Image Source="{Binding WifiImage}" Width="70" Height="53" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,2,0,0"/>
<Image Source="{Binding ConnectedImage}" Width="43" Height="63" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="45,7,0,0" />
</WrapPanel>
<WrapPanel>
<Label Content="{Binding ItemNO}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="35,0,0,0" FontWeight="Bold" FontSize="18"></Label>
<Label Content="{Binding Connected}" Name="lblconnected" Visibility="Collapsed"></Label>
</WrapPanel>
</WrapPanel>
</Button.Content>
</Button>
</DataTemplate>
Alternatively, you could use an event trigger from the Microsoft.Xaml.Behaviors.Wpf NuGet package. With this approach, the ClickCommand is invoked on mouse button up, it does not change any style.
<DataTemplate>
<WrapPanel Width="135" Height="160" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,1,0,0">
<b:Interaction.Triggers>
<b:EventTrigger EventName="MouseLeftButtonUp">
<b:InvokeCommandAction Command="{Binding ClickCommand}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
<WrapPanel Background="{StaticResource connRectangle}" Width="133" Height="128">
<Image Source="{Binding WifiImage}" Width="70" Height="53" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="35,2,0,0"/>
<Image Source="{Binding ConnectedImage}" Width="43" Height="63" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="45,7,0,0" />
</WrapPanel>
<WrapPanel>
<Label Content="{Binding ItemNO}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="35,0,0,0" FontWeight="Bold" FontSize="18"></Label>
<Label Content="{Binding Connected}" Name="lblconnected" Visibility="Collapsed"></Label>
</WrapPanel>
</WrapPanel>
</DataTemplate>

xceed IntegerUpdown's TabIndex has no effect

I have 4 IntegerUpDowns from the Xceed toolkit. The problem is that the navigation through Tab button does not work at all. I set TabIndex, TabStop properties, but no effect. Maybe somebody had this problem? Any help will be appreciate! Thanks a lot!
Here is a code:
<GroupBox Margin="20"
HorizontalAlignment="Center"
Header="groupbox header text">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Margin="7"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="text1:" />
<xctk:IntegerUpDown Name="updown1"
Width="50"
Height="25"
Margin="17,0,30,0"
TabIndex="0"
IsTabStop="True"
VerticalAlignment="Center"
Increment="1"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
ValueChanged="Updown1_OnValueChanged"
Value="{Binding Property1,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="text2" />
<xctk:IntegerUpDown Name="updown2"
Width="50"
Height="25"
Margin="43,0,0,0"
VerticalAlignment="Center"
Increment="2"
TabIndex="2"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
Value="{Binding Property2,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Grid.Row="1"
Margin="7,0,7,7"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="text3:" />
<xctk:IntegerUpDown Name="updown3"
Width="50"
Height="25"
Margin="7,0,30,0"
VerticalAlignment="Center"
Increment="1"
TabIndex="1"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
ValueChanged="Updown3_OnValueChanged"
Value="{Binding Proeprty3,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="text4:"/>
<xctk:IntegerUpDown Name="updown4"
Width="50"
Height="25"
Margin="7,0,0,0"
TabIndex="3"
VerticalAlignment="Center"
Increment="1"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
Value="{Binding Property4,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</GroupBox>

How do I set focus in side an autocomplete textbox

I have downloaded 3rd party autocomplete textbox and referenced it in my project. I have 3 autocomplete textboxes FirstName, LastName, ReceiptNo. When the form loads I want the firstname to be in focus. How to achieve this.
I have tried several steps like
//Eventhandler while form loads
private void Page_Loaded_1(object sender, RoutedEventArgs e)
{
FirstName.Focus();
}
or
//Eventhandler while autocomplete textbox loads
void FirstName_GotFocus(object sender, RoutedEventArgs e)
{
FirstName.Focus();
}
I also tried creating a bool isvisible property and binding it to autocomplete FirstName textbox in Xaml but that does not works. Any help will be appreciated.
My xaml code is given below
<wpf:AutoCompleteTextBox Style="{StaticResource AutoComp}"
Height="32"
Canvas.Left="33"
ToolTip="First Name"
Canvas.Top="120"
Width="205"
Padding="10,5"
TabIndex="1001"
VerticalAlignment="Top"
Loaded="FirstName_GotFocus"
Watermark=""
IconPlacement="Left"
IconVisibility="Visible"
Delay="100"
Text="{Binding FirstName, Mode=TwoWay, TargetNullValue=''}"
Provider="{Binding FirstNameSuggestions}">
<wpf:AutoCompleteTextBox.ItemTemplate>
<DataTemplate>
<Border Padding="5">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding}"
FontWeight="Bold" />
</StackPanel>
</Border>
</DataTemplate>
</wpf:AutoCompleteTextBox.ItemTemplate>
</wpf:AutoCompleteTextBox>
<Label Style="{StaticResource Devlbl}"
Canvas.Left="250"
Content="Last Name"
Canvas.Top="90" />
<wpf:AutoCompleteTextBox Style="{StaticResource AutoComp}"
Height="32"
ToolTip="Last Name"
Canvas.Left="250"
Canvas.Top="120"
Width="205"
Padding="10,5"
TabIndex="1002"
VerticalAlignment="Top"
Watermark=""
IconPlacement="Left"
IconVisibility="Visible"
Delay="100"
Text="{Binding LastName, Mode=TwoWay, TargetNullValue=''}"
Provider="{Binding LastNameSuggestions}">
<wpf:AutoCompleteTextBox.ItemTemplate>
<DataTemplate>
<Border Padding="5">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding}"
FontWeight="Bold" />
</StackPanel>
</Border>
</DataTemplate>
</wpf:AutoCompleteTextBox.ItemTemplate>
</wpf:AutoCompleteTextBox>
</Label>
<Label Style="{StaticResource Devlbl}"
Canvas.Left="480"
Content="Receipt No"
Canvas.Top="90" />
<!--<TextBox Canvas.Left="480"
ToolTip="Receipt No"
Canvas.Top="107"
Width="205"
MaxLength="10"
TabIndex="1003"
Style="{StaticResource CommonTextBox}"
Text="{Binding ReceiptNo,TargetNullValue=''}">
<i:Interaction.Behaviors>
<b:AllowableCharactersTextBoxBehavior RegularExpression="^[0-9]+$" MaxLength="10" />
</i:Interaction.Behaviors>
</TextBox>-->
<wpf:AutoCompleteTextBox Style="{StaticResource AutoComp}"
Height="32"
ToolTip="Receipt No"
Canvas.Left="480"
Canvas.Top="120"
Width="205"
Padding="10,5"
TabIndex="1002"
VerticalAlignment="Top"
Watermark=""
IconPlacement="Left"
IconVisibility="Visible"
Delay="100"
Text="{Binding ReceiptNo, Mode=TwoWay, TargetNullValue=''}"
e:FocusExtension.IsFocused="{Binding IsFocused, Mode=TwoWay }"
Provider="{Binding ReceiptIdSuggestions}">
<wpf:AutoCompleteTextBox.ItemTemplate>
<DataTemplate>
<Border Padding="5">
<StackPanel Orientation="Vertical" >
<TextBlock Text="{Binding}"
FontWeight="Bold">
</TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</wpf:AutoCompleteTextBox.ItemTemplate>
<i:Interaction.Behaviors>
<b:AllowableCharactersTextBoxBehavior RegularExpression="^[0-9]+$" MaxLength="15" />
</i:Interaction.Behaviors>
</wpf:AutoCompleteTextBox>
</Label>
Your first attempt is very close. Try doing the following in the Page_Loaded_1 event handler
this.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
(Note - MoveFocus is a method on the Window class, it's not something you need to implement)
You should define your textboxes to have tab-indices. After the page loads, the TraversalRequest will give focus to the first tab-indexed control. If no tab indices are defined I believe it will give focus to the top of the UI hierarchy, so technically the main window would receive focus in that case.
For reference, here's an MSDN link to all of the FocusNavigationDirection options.
I changed the code as shown below and its working fine. I added a cavas as container and placed my auto complete textbox inside the canvas.
FocusNavigationDirection focusDirection = FocusNavigationDirection.Next;
// MoveFocus takes a TraveralReqest as its argument.
TraversalRequest request = new TraversalRequest(focusDirection);
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
if (elementWithFocus != null)
{
elementWithFocus.MoveFocus(request);
}

ListBoxItem Should be Visible while Draging From one ListBox to another in WPF

Click Here to View ImageI am implementing Drag& Drop in wpf. I want when i dragged ListBoxItem From one Listbox to another. that listboxitem should be visible while dragging.Do i missing Something ?
XAML
<Grid x:Name="MainGrid" Width="{Binding ElementName=ProjectWindow,Path=ActualWidth}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19*" />
<ColumnDefinition Width="283*" />
<ColumnDefinition Width="59*" />
<ColumnDefinition Width="19*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="7*" />
<RowDefinition Height="83*" />
</Grid.RowDefinitions>
<Canvas Grid.Row="0" >
<Label Content="TM" FontSize="14" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="118" Canvas.Top="-4"></Label>
<Label Content="smart" FontSize="26" Foreground="White" FontFamily="segoe_uilight"></Label>
<Label Content="Project" FontSize="26" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="64" FontWeight="Bold"></Label>
<TextBlock Canvas.Left="164" Canvas.Top="15" Background="Black">
<Label Background="Black" Content="From" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="164" Canvas.Top="15" ></Label>
<DatePicker x:Name="StartDate" Width="100" Background="Black" Canvas.Left="204" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="Till" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<DatePicker x:Name="EndDate" Width="100" Background="Black" Canvas.Left="344" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="My Activities" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<CheckBox x:Name="ChckBoxMyActivities" Click="ChckBoxMyActivities_Click_1" Background="Black" Margin="0,0,0,5" Width="20"></CheckBox>
<Label Background="Black" Content="Project Component" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<ComboBox x:Name="ComboBoxSubProjects" SelectionChanged="ComboBoxSubProjects_SelectionChanged_1" Background="Black" Margin="0,0,0,5" Width="100" ></ComboBox>
</TextBlock>
<Expander HorizontalAlignment="Right" FlowDirection="RightToLeft" Foreground="White" FontFamily="segoe_uilight" Width="200px" Canvas.Top="1" Canvas.Right="200" Canvas.Left="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}" BorderBrush="#FF0A0909" BorderThickness="1,1,1,2" Background="#BF080707" Panel.ZIndex="99999">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Canvas Height="22" Width="172px" VerticalAlignment="Bottom">
<Label x:Name="LoginUserName" Margin="0px 0 0 0" HorizontalAlignment="Left" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0"></Label>
<Image Source="img\icons\dropdown_user.png" Height="20px" Width="20px" RenderTransformOrigin="2.75,0.8" Canvas.Left="117" />
</Canvas>
</StackPanel>
</Expander.Header>
<!--<Expander.Content>
<TextBox Text="LoginUserName"></TextBox>
</Expander.Content>-->
<StackPanel Margin="10,4,0,0" >
<StackPanel Orientation="Horizontal">
<Label x:Name="lblSettings" Margin="49px 0 31px 0" HorizontalAlignment="Left" Content="Settings" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" RenderTransformOrigin="2.019,0.625">
</Label>
<Image Source="img\icons\setting.png" Height="20px" Width="20px" />
</StackPanel>
<!--<Label Margin="4" Content="Logout" />-->
<!--<Button x:Name="btnLogout" Margin="4" Content="Logout" Click="btnLogout_Click_1"></Button>-->
<StackPanel Orientation="Horizontal">
<Label x:Name="btnLogout" HorizontalAlignment="Left" Margin="54px 0 31px 0" Content="Logout" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0">
</Label>
<Image Source="img\icons\logout.png" Height="20px" Width="20px" />
</StackPanel>
</StackPanel>
</Expander>
</Canvas>
<Canvas Grid.Column="0" Grid.Row="1" Background="Orange">
<StackPanel Canvas.Left="10" Background="Gray" Width="60" >
<Image Source="img\icons\information.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="45" Background="Gray" Width="60" >
<Image Source="img\icons\Scheme.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Schema" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\Tavala.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Tavla" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
<Canvas x:Name="gd" Grid.Column="1" Grid.Row="1" Panel.ZIndex="-1" Background="Orange">
<Grid Width="{Binding ElementName=gd, Path=ActualWidth}" Panel.ZIndex="-1">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Canvas Grid.Column="1" Grid.Row="0" >
<Canvas x:Name="MainCanvas" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBoxItem>
<ListBox Loaded="icTodoList_Loaded_1" Background="Azure" SelectionChanged="icTodoList_SelectionChanged_1" Name="icTodoList" Height="50" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="Phases" BorderThickness="0">
<ListBoxItem>
<Canvas x:Name="PhaseCanvas" Height="20" Width="200" Margin="0,0,20,20" >
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="txtPhaseID" TextAlignment="Center" FontWeight="Light" HorizontalAlignment="Center" FontSize="16" Foreground="Black" FontFamily="segoe_uilight" Text="{Binding PhaseTitle}" Height="20" Width="140" />
<Image Margin="20,0,0,0" Tag="{Binding PhaseID}" Source="img\icons\add_btn.png" Width="20" Height="15" MouseUp="Image_MouseUp_1"></Image>
<!--<TextBlock HorizontalAlignment="Left" FontFamily="segoe_uilight" FontStyle="Italic" Text="{Binding UserName}" Height="20" Width="180" />
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="segoe_uilight" Text="{Binding ThreadDescription}" Height="45" Width="200" />-->
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
<ListBoxItem>
<ListBox Loaded="ActivityListBox_Loaded_1" Background="Orange" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="InnerActivityListBox" Tag="{Binding PhaseID}" Width="225" Height="{Binding ElementName=gd,Path=ActualHeight}" Background="Orange" PreviewMouseLeftButtonDown="InnerActivityListBox_PreviewMouseLeftButtonDown_1" AllowDrop="True" DragEnter="InnerActivityListBox_DragEnter_1" Drop="InnerActivityListBox_Drop_1" DragOver="InnerActivityListBox_DragOver_1" BorderThickness="0">
<!--<ListBoxItem>-->
<!--<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>-->
<!--</ListBoxItem>-->
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
</ListBox>
<!--<ListBox Loaded="ActivityListBox_Loaded_1" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Canvas.Top="100" Width="{Binding ElementName=gd,Path=ActualWidth}" Background="Orange">
<ListBox.ItemTemplate >
<DataTemplate>
<ListBox x:Name="InnerActivityListBox">
<ListBoxItem>
<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>-->
<!--<Canvas Width="200" Height="50" Background="White" Canvas.Left="46" Canvas.Top="10">
<TextBlock FontWeight="Bold" Height="50" Width="10" Canvas.Left="0" Background="Gray"></TextBlock>
<TextBlock Text="Header Style" FontWeight="Bold" Canvas.Top="2" Canvas.Left="15"></TextBlock>
<TextBlock Text="Schedule" Canvas.Top="14" Canvas.Left="15"></TextBlock>
<TextBlock Text="1 Jan-3Mar" Canvas.Top="7" Canvas.Left="110"></TextBlock>
<Image Source="img/icons/icon.png" Canvas.Left="15" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_1.png" Canvas.Left="45" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_2.png" Canvas.Left="75" Canvas.Bottom="5"></Image>
<Image Source="img/icons/t3.png" Canvas.Left="105" Canvas.Bottom="5"></Image>
</Canvas>-->
</Canvas>
</Canvas>
</Grid>
</Canvas>
<Canvas x:Name="cn" Grid.Column="2" Grid.Row="1" Background="White" MouseUp="Canvas_MouseUp_1">
<!--`ActivityInfo Popup up-->
<Canvas x:Name="ActivityInfo" Background="Green" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="ActivityInfo_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="projectdescrption" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Information" Canvas.Left="10" ></TextBlock>
<Canvas Background="White" Height="900" Width="200" Canvas.Top="50" Canvas.Left="10">
<StackPanel Width="200" Height="900" Background="White" Orientation="Vertical" >
<TextBlock x:Name="ActivityTitle" Text="Title" FontFamily="segoe_uilight" FontSize="18" Foreground="Black"></TextBlock>
<TextBlock x:Name="txtActivityTitle" Text="Page Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ProjectCompnt" Text="Project Component" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtProjectCompnt" Text="Project Component Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Phase" Text="Phase" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtPhase" Text="Phase Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Start" Text="Start" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtStart" Text="2014-1-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="End" Text="End" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtEnd" Text="2014-2-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Activitydescrption" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Description" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivitydescrption" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ActivityRequirement" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Requirement" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivityRequirement" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<Button x:Name="btnsave" Content="Save" Foreground="Black" Height="30" Width="100" HorizontalAlignment="Right" Background="#FFF3800C"></Button>
</StackPanel>
</Canvas>
</Canvas>
<!--`Activity Comments-->
<Canvas x:Name="Comments" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="Comments_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="ActivityComments" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="23" Text="Comments" Canvas.Left="35"></TextBlock>
<TextBox x:Name="txtComments" Height="110" Width="200" BorderBrush="Black" TextWrapping="Wrap" Canvas.Top="40" Canvas.Left="5" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"></TextBox>
<Button x:Name="btnsavecomments" Content="Send" Foreground="Black" Height="30" Width="100" Canvas.Top="170" Canvas.Left="35" Background="#FFF3800C"></Button>
<ListBox Canvas.Top="220" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" >
<Border BorderThickness="2,2,2,2" CornerRadius="4" Background="#E26806">
<TextBlock x:Name="txtthreadComments" Height="Auto" Width="190" TextWrapping="Wrap" Background="#E26806" Text="g rg rg r g rg rg rg rg er gre ger ger g g gr" Foreground="White" ></TextBlock>
</Border>
<Image x:Name="imgthread" Height="30" Width="30" Margin="-100,-12,0,0" Source="D:\Amrit\Working Code\smart Info WPF app\SmartInfo\SmartAccount\SmartAccount\img\tol_tip.jpg"></Image>
<TextBlock x:Name="threadtime" Text="2014-6-7 12:00" HorizontalAlignment="Stretch" Margin="0,0,10,0" FontStyle="Italic" Height="20" Width="150" Foreground="Black" FontSize="16"></TextBlock>
<TextBlock x:Name="threadPostedBy" Text="Amrit Verma" Height="20" Width="150" Foreground="Black" FontStyle="Italic" FontWeight="Bold" FontSize="15"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
<!-- Assigned Memebres -->
<Canvas x:Name="AssignedMemebres" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" Visibility="Hidden">
<TextBlock x:Name="Memebres" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Assigned Members" Canvas.Left="30"></TextBlock>
<ListBox Canvas.Top="40" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<TextBlock x:Name="AssignMemeber" Foreground="Black" FontFamily="segoe_uilight" FontSize="14" Text="+ Assign Memeber" FontStyle="Italic" Canvas.Left="12" Canvas.Top="-3"></TextBlock>
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" Canvas.Left="20">
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedto" Text="Amrit Verma" FontWeight="Bold"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedrole" Text="Developer" ></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Email" Text="Email" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtEmail" Text="Amrit#gmail.com" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Phone" Text="Phone" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtPhone" Text="555-111 442 213" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingHours" Text="Working Hours" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingHours" Text="9:00 - 12:00" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingDays" Text="Working Days" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingDays" Text="Mon-Sat" FontStyle="Italic"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
</Canvas>
<Canvas Grid.Column="3" Grid.Row="1" Background="Orange" >
<StackPanel Canvas.Left="0" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_1" x:Name="stackpnlinfo">
<Image Source="img\icons\icon.png" Height="20px" Width="20px" />
<!--<Image Source="img\btn_img.jpg" Height="45px" Width="60px" />-->
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" ></Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="45" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_2" x:Name="stackpnlcomment">
<Image Source="img\icons\icon_1.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Comments" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\icon_2.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Files" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="135" Background="Gray" Width="60" x:Name="AssignedMembrs" MouseUp="AssignedMembrs_MouseUp_1">
<Image Source="img\icons\at.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Assigned Members" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
</Grid>
c#
private void InnerActivityListBox_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
if (_dragged != null)
return;
UIElement element = Phaseitem.InputHitTest(e.GetPosition(Phaseitem)) as UIElement;
while (element != null)
{
if (element is ListBoxItem)
{
_dragged = (ListBoxItem)element;
break;
}
element = VisualTreeHelper.GetParent(element) as UIElement;
}
SourcePhaseID = Phaseitem.Tag.ToString();
Globallb = Phaseitem;
Globallbi = _dragged;
Phaseitem.Items.Remove(_dragged);
}
private void InnerActivityListBox_DragEnter_1(object sender, DragEventArgs e)
{
if (_dragged == null || e.Data.GetDataPresent(DataFormats.Text, true) == false)
e.Effects = DragDropEffects.None;
else
e.Effects = DragDropEffects.All;
}
private void InnerActivityListBox_Drop_1(object sender, DragEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
DestinationPhaseID = Phaseitem.Tag.ToString();
Phaseitem.Items.Add(_dragged);
}
private void InnerActivityListBox_DragOver_1(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.Move;
}
If this is you are trying to achieve. This also include designing your own Adorner to be shown as Ghost Perview while dragging
http://www.codeproject.com/Articles/43702/Drag-and-Drop-in-WPF-Part-II
and this article has vanilla code and doing exactly what you want
http://www.essentialobjects.com/doc/5/controls/treeview/dragdrop.aspx#list_box

Use styles define in application resources

I'm having problem using any styles that are defined in my Application resources in another classes. These are the contents of my App.xaml class. When I try to apply the TextBox class I get error: cannot find named resource "validationTextboxStyle"
<Application x:Class="ClientApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
StartupUri="LoginWindow.xaml">
<Application.Resources>
<Style x:Key="validationTextboxStyle" TargetType="TextBox">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Right"
Foreground="Orange"
FontSize="12pt">
!!!!
</TextBlock>
<Border BorderBrush="Green" BorderThickness="1">
<AdornedElementPlaceholder />
</Border>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
<Application.MainWindow>
<NavigationWindow Source="Main.xaml"></NavigationWindow>
</Application.MainWindow>
I try to use the style in another window.
<Window x:Class="ClientApp.NewItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:validation="clr-namespace:ClientApp.ValidationRules"
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
Height="520" Width="400"
WindowStartupLocation="CenterOwner">
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommands.Save"
CanExecute="SaveCanExecute"
Executed="SaveExecuted" />
</Window.CommandBindings>
<Window.Resources>
</Window.Resources>
<TabControl Height="Auto" Name="tabControl1" Width="Auto">
<TabItem Header="General" Name="tabItem1">
<extToolkit:BusyIndicator x:Name="busyIndicator" Visibility="Visible">
<Grid Name="contentGrid">
<extToolkit:ChildWindow Name="generateWindowChild" IsModal="True" Height="222" Width="300" WindowStartupLocation="Center" Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="0" Grid.RowSpan="10">
<Grid>
<TextBox Height="23" HorizontalAlignment="Left" Margin="12,14,0,0" Name="txt_password" VerticalAlignment="Top" Width="242" />
<CheckBox Content="Numbers" IsChecked="True" Height="16" HorizontalAlignment="Left" Margin="16,79,0,0" Name="chk_numbers" VerticalAlignment="Top" />
<Button Content="Generate" Height="23" HorizontalAlignment="Left" Margin="58,152,0,0" Name="btn_generatePass" VerticalAlignment="Top" Width="75" Click="btn_generatePass_Click" />
<CheckBox Content="Upper case letters" IsChecked="True" Height="16" HorizontalAlignment="Left" Margin="16,123,0,0" Name="chk_special" VerticalAlignment="Top" />
<CheckBox Content="Special characters" IsChecked="True" Height="16" HorizontalAlignment="Left" Margin="16,101,0,0" Name="chk_upper" VerticalAlignment="Top" />
<Button Content="Insert" Height="23" HorizontalAlignment="Left" Margin="145,152,0,0" Name="btn_InsertPass" VerticalAlignment="Top" Width="75" Click="btn_InsertPass_Click" />
<extToolkit:IntegerUpDown DefaultValue="8" Value="8" Height="25" Width="35" Visibility="Visible" Margin="88,46,145,115" Name="minUpDown" PreviewKeyDown="minUpDown_PreviewKeyDown" ValueChanged="minUpDown_ValueChanged" />
<extToolkit:IntegerUpDown DefaultValue="8" Value="8" Height="25" Width="35" Margin="0,46,24,115" Name="maxUpDown" PreviewKeyDown="maxUpDown_PreviewKeyDown" ValueChanged="maxUpDown_ValueChanged" HorizontalAlignment="Right" />
<Label Content="Min length:" Height="28" HorizontalAlignment="Left" Margin="16,45,0,0" Name="minLengthLabel" VerticalAlignment="Top" />
<Label Content="Max length:" Height="28" HorizontalAlignment="Right" Margin="0,45,69,0" Name="maxLengthLabel" VerticalAlignment="Top" />
</Grid>
</extToolkit:ChildWindow>
<TextBox HorizontalAlignment="Left" Style="{StaticResource validationTextboxStyle}" VerticalAlignment="Top" Width="120" Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" LostFocus="TextBox_LostFocus">
<TextBox.Text>
<Binding Path="GroupName" UpdateSourceTrigger="LostFocus" Mode="TwoWay">
<Binding.ValidationRules><validation:ItemGroupNameValidationRule /></Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox HorizontalAlignment="Left" Style="{StaticResource validationTextboxStyle}" VerticalAlignment="Top" Width="120" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" >
<TextBox.Text>
<Binding Path="Title" UpdateSourceTrigger="LostFocus" Mode="TwoWay">
<Binding.ValidationRules><validation:ItemTitleValidationRule /></Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2">
<TextBox.Text>
<Binding Path="username" UpdateSourceTrigger="LostFocus" Mode="TwoWay">
<Binding.ValidationRules><validation:ItemUsernameValidationRule /></Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<PasswordBox HorizontalAlignment="Left" Name="txt_itemPassword" VerticalAlignment="Top" Width="120" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="2" LostFocus="txt_itemPassword_LostFocus" />
<PasswordBox HorizontalAlignment="Left" Name="txt_ConfirmPassword" VerticalAlignment="Top" Width="120" Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="2" LostKeyboardFocus="txt_ConfirmPassword_LostKeyboardFocus" />
<Button Content="Generate" HorizontalAlignment="Left" Name="btn_generateNewPass" VerticalAlignment="Top" Width="36" Click="btn_generateNewPass_Click" Grid.Row="6" Grid.Column="4" Grid.ColumnSpan="2"/>
<TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="2" >
<TextBox.Text>
<Binding Path="Url" UpdateSourceTrigger="LostFocus" Mode="TwoWay">
<Binding.ValidationRules><validation:ItemUrlValidationRule /></Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox Height="80" Width="200" Background="White" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="8" Grid.Column="2" Grid.ColumnSpan="6">
<TextBox.Text>
<Binding Path="Note" UpdateSourceTrigger="LostFocus" Mode="TwoWay">
<Binding.ValidationRules><validation:ItemNoteValidationRule /></Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<ListBox Height="80" HorizontalAlignment="Left" BorderBrush="LightGray" Name="listBox_Roles" VerticalAlignment="Top" Width="200" Grid.Row="9" Grid.Column="2" Grid.ColumnSpan="4">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Title}" Checked="checkBoxChanged" Unchecked="checkBoxChanged"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label Content="Group" HorizontalAlignment="Left" Name="label9" VerticalAlignment="Top" Grid.Row="2" Grid.Column="1" />
<Label Content="Title" HorizontalAlignment="Left" Name="label1" VerticalAlignment="Top" Grid.Row="3" Grid.Column="1"/>
<Label Content="Username" HorizontalAlignment="Left" Name="label2" VerticalAlignment="Top" Grid.Row="4" Grid.Column="1"/>
<Label Content="Password" HorizontalAlignment="Left" Name="label3" VerticalAlignment="Top" Grid.Row="5" Grid.Column="1"/>
<Label Content="Confirm Password" HorizontalAlignment="Left" Name="label7" VerticalAlignment="Top" Grid.Row="6" Grid.Column="1"/>
<Label Content="Url" HorizontalAlignment="Left" Name="label5" VerticalAlignment="Top" Grid.Row="7" Grid.Column="1"/>
<Label Content="Note" HorizontalAlignment="Left" Name="label4" VerticalAlignment="Top" Grid.Row="8" Grid.Column="1"/>
<Label Content="Roles" HorizontalAlignment="Left" Name="label8" VerticalAlignment="Top" Grid.Row="9" Grid.Column="1"/>
<Button Content="Create" Command="ApplicationCommands.Save" IsDefault="True" HorizontalAlignment="Left" Name="btn_CreateItem" VerticalAlignment="Top" Width="75" Grid.Row="11" Grid.Column="2"/>
<Button Content="Cancel" HorizontalAlignment="Right" IsCancel="True" Name="btn_CancelCreateItem" VerticalAlignment="Top" Width="75" Click="btn_CancelCreateItem_Click" Grid.Row="11" Grid.Column="3" Grid.ColumnSpan="2"/>
</Grid>
</extToolkit:BusyIndicator>
</TabItem>
<TabItem Header="Expiration" Name="tabItem2">
<GroupBox Header="Expiration Rule" Height="229" Name="groupBox1" Width="469" VerticalAlignment="top" HorizontalAlignment="Left">
<Grid Height="210">
<Grid.RowDefinitions>
<RowDefinition Height="66*" />
<RowDefinition Height="144*" />
</Grid.RowDefinitions>
<RadioButton GroupName="passwordExpiration" Content="Never" IsChecked="True" Height="16" HorizontalAlignment="Left" Margin="38,22,0,0" Name="radioExpiresNever" VerticalAlignment="Top" />
<RadioButton GroupName="passwordExpiration" Content="In" Height="16" Name="radioExpiresInDays" Margin="36,65,-36,129" Grid.RowSpan="2" />
<extToolkit:IntegerUpDown Name="expiresInDaysUpDown" Margin="152,61,232,127" Height="22" Grid.RowSpan="2"></extToolkit:IntegerUpDown>
<Label Name="daysRecurring" Content="Days" Margin="231,58,0,117" HorizontalAlignment="Left" Width="38" Grid.RowSpan="2"></Label>
<RadioButton GroupName="passwordExpiration" Content="On" Height="16" HorizontalAlignment="Left" Margin="38,38,0,0" Name="radioExpiresDate" VerticalAlignment="Top" Grid.Row="1" />
<extToolkit:DateTimePicker Name="expirationDate" Width="203" Height="21" Margin="152,40,102,83" Grid.Row="1"></extToolkit:DateTimePicker>
</Grid>
</GroupBox>
</TabItem>
</TabControl>

Resources