|
I can't praise them enough. The way I view it is, would I use this control if I had to pay for it myself? And I did.
|
|
|
|
|
Good, thanks! +5
If it's not broken, fix it until it is
|
|
|
|
|
High praise indeed.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a DataTemplate which, when referenced, displays a Slider Bar. The setup of the slider is dependant on data passed to the Form from the calling class. The XAML for the config looks like this.
<pre lang="xml">
<Window.Resources>
<DataTemplate DataType="{x:Type ContentControl}" x:Key="TextBoxTemplate">
<TextBox Text="{Binding ElementName=MyWindow, Path=m_csValue}" Height="23"/>
</DataTemplate>
<DataTemplate DataType="{x:Type ContentControl}" x:Key="SliderTemplate">
<Slider Name="sli" Value="{Binding ElementName = MyWindow, Path=sli}" ValueChanged="OnSliderValueChanged" IsSnapToTickEnabled="True" Margin="5" />
</DataTemplate>
<Style TargetType="{x:Type ContentControl}" x:Key="DisplayValues">
<Setter Property="ContentTemplate" Value="{StaticResource TextBoxTemplate}" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=MyWindow, Path=eType}" Value="{x:Static local:eTagDisplay.Text}">
<Setter Property="ContentTemplate" Value="{StaticResource TextBoxTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=MyWindow, Path=eType}" Value="{x:Static local:eTagDisplay.Slider}">
<Setter Property="ContentTemplate" Value="{StaticResource SliderTemplate}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid Width="267">
<StackPanel Margin="0,37,0,133" Height="123">
<TextBlock Height="23" Name="textBlock1" Text="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<ContentControl Style="{StaticResource DisplayValues}" Margin="12,12,12,158" />
</Grid>
</pre>
In my Code Behind I set up the Max, Min, Tick Frequency and Value when the Form is created.
When the Slider bar is updated i find that the slider in the code behind is not bound to the slider on display, and so I'm not updating the value of the object I wish to update.
How can I ensure that the slider created in the XAML is bound to the slider in the code behind?
Regards
Tony
|
|
|
|
|
In my project I have this xaml code for my slider
<StatusBarItem Grid.Column="5" Padding="4,0,15,0">
<StackPanel x:Name="StatusBarSlider" Orientation="Horizontal">
<TextBlock x:Name="StatusBarItem"
Margin="0,1,0,1"
Foreground="{Binding Foreground,
ElementName=navigationPane}"
Padding="6,0,6,0"
Text="{Binding Value,
ConverterParameter=%,
Converter={StaticResource PercentageConverter},
ElementName=scaleSlider}" />
<RepeatButton Margin="1,0,1,0"
CommandTarget="{Binding ElementName=scaleSlider}"
ribbon:ScreenTipService.ScreenTipHeader="Zoom Out"
Style="{StaticResource {x:Static themes:SharedResourceKeys.StatusBarEmbeddedSliderDecreaseButtonBaseStyleKey}}" />
<Slider x:Name="scaleSlider"
Width="100"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
LargeChange="0.5"
Maximum="2.0"
Minimum="0.5"
ribbon:ScreenTipService.ScreenTipHeader="Zoom"
SmallChange="0.1"
TickFrequency="0.1"
Value="1.0" />
<RepeatButton Margin="1,0,1,0"
CommandTarget="{Binding ElementName=scaleSlider}"
ribbon:ScreenTipService.ScreenTipHeader="Zoom In"
Style="{StaticResource {x:Static themes:SharedResourceKeys.StatusBarEmbeddedSliderIncreaseButtonBaseStyleKey}}" />
</StackPanel>
</StatusBarItem>
My code Behind this is
ScaleTransform scaleTransform = new ScaleTransform();
Binding scaleXBinding = new Binding("Value");
scaleXBinding.Source = scaleSlider;
Binding scaleYBinding = new Binding("Value");
scaleYBinding.Source = scaleSlider;
BindingOperations.SetBinding(scaleTransform,
ScaleTransform.ScaleXProperty,
scaleXBinding);
BindingOperations.SetBinding(scaleTransform,
ScaleTransform.ScaleYProperty,
scaleYBinding);
and since I am scaling something being displayed inside a tab I use this
newTab.Content = Contact2;
Contact2.contentContainer.LayoutTransform = scaleTransform;
This binds the slider control to the contents of my contacts. Hope this helps.
|
|
|
|
|
Hi,
Thanks for your response, I've only just managed to pick this up.
I've looked at your code sample, many thanks.
The issue that I'm seeing is that using the "Name" declared for the Slider, I cannot use it in my CodeBehind without declaring an independent Slider object - which creates and new object and doesnt bind to the declared Slider in the XAML.
As the Slider is named and delcared in a the <Windows.Resources> section, and as part of a <DataTemplate>, do I need to reference by more than just the object name, e.g. would I need to call it something like someItem.sli as opposed to just sli?
Regards
Tony
|
|
|
|
|
How does one define IOleServiceProvider in a C# WPF application?
I was told that it was automatically recogized if I downloaded and installed the visual studio SDK. Is there some extra step I am missing?
http://i67.photobucket.com/albums/h292/Athono/programming/12-9-2012.png
IOleServiceProvider is from the Namespace Microsoft.TeamFoundation...
But I cannot declare this:
http://i67.photobucket.com/albums/h292/Athono/programming/12-9-2012-2.png
|
|
|
|
|
Are you trying to use this from a Visual Studio addin? That's what the VS SDK IOleServiceProvider is present in. Here's[^] an example using it.
|
|
|
|
|
<pre>
<HierarchicalDataTemplate DataType="{x:Type local:RegionViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Region.png" />
<TextBlock Text="{Binding RegionName}" />
</StackPanel>
</HierarchicalDataTemplate>
</pre>
Hi in the above data template whenever the type is a region, it says to use a particular icon.
But I want to chose icon based on the name of the region! Could you please let me know How I do this please?
Regards
RK
|
|
|
|
|
|
I have a combo box of lookup items. It's bound to an ObservableCollection of LookupEntity. The code-behind:
private ObservableCollection<LookupEntity> _EmployeeTypes;
public ObservableCollection<LookupEntity> EmployeeTypes
{
get { return _EmployeeTypes; }
set
{
if (_EmployeeTypes != value)
{
_EmployeeTypes = value;
RaisePropertyChanged("EmployeeTypes");
}
}
}
private LookupEntity _SelectedEmployeeType;
public LookupEntity SelectedEmployeeType
{
get { return _SelectedEmployeeType; }
set
{
if (_SelectedEmployeeType != value)
{
_SelectedEmployeeType = value;
RaisePropertyChanged("SelectedEmployeeType");
}
}
}
and
public override void RefreshView()
{
ViewHeaderText = "Employee - " + employee.FullName;
FirstName = employee.FirstName;
LastName = employee.LastName;
SelectedEmployeeType = employee.EmployeeType;
}
the XAML
<ComboBox Grid.Row="2"
Grid.Column="1"
Width="120"
HorizontalAlignment="Left"
ItemsSource="{Binding EmployeeTypes}"
SelectedItem="{Binding SelectedEmployeeType, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Caption}">
<TextBlock.ToolTip>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Caption}"
FontWeight="Bold"/>
<TextBlock Text="{Binding Description}"/>
</StackPanel>
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
The combo item is not being selected. Anyone see what's wrong?
If it's not broken, fix it until it is
|
|
|
|
|
As a quick solution you can use SelectedIndex bind to an int property.
|
|
|
|
|
If you want your combobox to automatically select the employee's type, then you need to set the SelectedValue and SelectedValuePath properties as well, something like this :-
<ComboBox Grid.Row="2"
Grid.Column="1"
Width="120"
HorizontalAlignment="Left"
SelectedValue="{Binding Path=SelecetdEmployee.SelecetdEmployeeType.EmpoyeeTypeID}"
SelecetdValuePath="EmployeeTypeID"
ItemsSource="{Binding EmployeeTypes}"
SelectedItem="{Binding SelectedEmployeeType, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Caption}">
<TextBlock.ToolTip>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Caption}"
FontWeight="Bold"/>
<TextBlock Text="{Binding Description}"/>
</StackPanel>
</TextBlock.ToolTip>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Just note that it is important to set the SelectedValue and SelectedValuePath properties before setting the ItemsSource property for the bindings to work properly.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thjat did it!
Many thanks
+5
If it's not broken, fix it until it is
|
|
|
|
|
That did it!
Many thanks
+5
If it's not broken, fix it until it is
|
|
|
|
|
Glad to help!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I want to use at command on hyper terminal by using Nokia x2 00 mobile . but i can't even type command
on hyper terminal. it might be possible that i made mistake while connection set up of mob to pc
can anybody tell me what are the steps to connect mobile to hyper terminal
|
|
|
|
|
You posted this question in the wrong forum....unless X2 uses Silverlight.
|
|
|
|
|
I have an application where I have the possibility of changing between different CultureInfos (for English, Spanish etc.).
I would like to be able to converter to currency based on which Culture Info has been selected.
Fx. I have the value $4.5 but I would like to show 3.49 EUR when Spanish is selected.
The question is should the converter be as IValueConverter or is it possible to place it in the culture info since this would be easier for me?
|
|
|
|
|
Use a ViewModel to hold the calculated value. A value converter is a little bit overkill for this purpose.
|
|
|
|
|
|
I'm trying to create a single control (Ratings) with a Textblock and a Dependency property
Ratings.XAML:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestControl"
mc:Ignorable="d"
x:Class="TestControl.Ratings"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<TextBlock x:Name="RatingText" Text="{Binding Score}" Height="60" Margin="180,157,381,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
</Grid>
</UserControl>
and Ratings.xaml.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TestControl
{
public partial class Ratings : UserControl
{
public Ratings()
{
this.InitializeComponent();
}
public static readonly DependencyProperty ScoreProperty = DependencyProperty.Register( "Score", typeof(int), typeof(Ratings), new FrameworkPropertyMetadata(1));
public int Score
{
get { return (int)GetValue(ScoreProperty); }
set { SetValue(ScoreProperty, value); }
}
}
}
Then I'm trying to call it from a project changing the Dependency Parameter
XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestControl"
x:Class="TestControl.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<local:Ratings Score="20" Height="120" Margin="96,51,292,0" VerticalAlignment="Top"/>
</Grid>
</Window>
and cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace TestControl
{
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
}
}
But it isn't working!!! Can someone please tell me why???
|
|
|
|
|
You haven't set the DataContext for the UserControl :
public Ratings()
{
InitializeComponent();
LayoutRoot.DataContext = this;
}
NB: You'll probably want to set the DataContext on a child of the UserControl , not the UserControl itself; otherwise, you won't be able to bind the properties of the UserControl to the parent DataContext :
http://stackoverflow.com/a/13308966/124386[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi men
I have a listView called lw1.
When I use lw1.selectedItem, I can check which item is selected.
But, how I can know which item is alone highlighted by mouse cursor?
note:http://dl.dropbox.com/u/45898865/Immagine.jpg[^]
in picture 1
gimppoi is selected with one click of mouse cursor
in picture 2
gimppoi is selected with one click of mouse cursor
poweooooooooo has alone mouse cursor over the line
good idea
I had tried it yesterday without success.
private void buttonGV_Click(object sender, RoutedEventArgs e)
{
Attivita attivita = null;
for (int i = 0; i < listViewAttivita.Items.Count; i++ )
if ( listViewAttivita.IsMouseOver )
attivita = listViewAttivita.Items[i] as Attivita;
if ( listViewAttivita.IsMouseOver )
this test is needless, because I want know which row is selected. That test told me if the mouse is over one of all ListView rows.
Can you tell me what I should search to understand which row has the mouse over?
this is the XAML part. Does it help?
<ListView ItemsSource= "{Binding AttivitaCollection, UpdateSourceTrigger=PropertyChanged}" Height="206" HorizontalAlignment="Left" Margin="12,33,0,0" Name="listViewAttivita" VerticalAlignment="Top" Width="auto" SelectionChanged="listViewAttivita_SelectionChanged">
<ListView.Resources>
<med:ImageConverter x:Key="imageConverter"/>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Azioni registrate" Width="150" DisplayMemberBinding="{Binding nome, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<GridViewColumn Header="Stato" Width="auto" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Width="24" Name="buttonGV" Click="buttonGV_Click" Height="24" Background="Transparent" BorderBrush="Transparent">
<Image Source="{Binding Path=imgStato, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource imageConverter}}" />
</Button>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
I already posted this message
http://www.codeproject.com/Messages/4441464/highlight-list-view.aspx[^]
|
|
|
|
|
You're doing it wrong .
1) call the HitTest method to get the UIElement that is under the mouse.
2) chase up the VisualTree til you get a null or a ListViewItem.
|
|
|
|