Hi there I want to pint value in the field like I am using KMBT so if I put 2.5m, it should be 2500000 but my code is not working :
<StackPanel Grid.Row="6" Grid.Column="4" Orientation="Vertical" Name="clmProgramSubjectPremium">
<Label Content="Program Subject Premium" FontWeight="Bold" />
<tuc:TrippsTextEdit x:Name="txtProgramSubjectPremium"
InvalidValueBehavior="AllowLeaveEditor"
SelectAllOnGotFocus="True"
HorizontalContentAlignment="Center"
MaskSaveLiteral="False"
MaskUseAsDisplayFormat="False" MaskType="RegEx" Mask="[0-9. ]{0,16}[kKmMbBtTuU ]?"
DisplayFormatString="N0"
IsCurrencyEnabled="True"
CurrencyCD="{Binding Layer.CurrencyCD}"
EditValue="{Binding ProgramSubjectPremium, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
MaskIgnoreBlank="False"
LostFocus="txtProgramSubjectPremium_LostFocus"
IsReadOnly="{Binding Path=IsControlEnabled,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl},Converter={StaticResource IsReadOnlyConverter},UpdateSourceTrigger=PropertyChanged}">
</tuc:TrippsTextEdit>
</StackPanel>
Related
What is a good way to get rid of repeating XAML in different files. Example :
<StackPanel Grid.Row="8" Grid.Column="2" Style="{StaticResource ViewContentStyle}" Visibility="{Binding Type, Converter={StaticResource TypeToVisibility}}">
<ctl:NewLabel LabelContent="{x:Static common:LocalResources.UNameLabel}" LabelStyle="{DynamicResource ContentLabelStyle}"
ImageStyle="{DynamicResource ViewContentControlStyle}">
<ctl:ETextBox x:Name="UserName" HorizontalAlignment="Left" Style="{StaticResource {x:Type TextBox}}"
LostFocus="Textbox_OnLostFocus"
Text="{Binding Path=UserName, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True}">
</ctl:ETextBox>
</ctl:NewLabel>
</StackPanel>
<StackPanel Grid.Row="9" Grid.Column="2" Style="{StaticResource ViewContentStyle}" Visibility="{Binding SelectedAuthenticationType, Converter={StaticResource AuthToVisibility}}">
<StackPanel Orientation="Horizontal" KeyboardNavigation.TabNavigation="None">
<Label Style="{DynamicResource ContentLabelStyle}" Content="{x:Static common:LocalResources.UPasswordLabel}"/>
<AdornerDecorator>
<PwdBox x:Name="Password"
HorizontalAlignment="Left"
LostFocus="Textbox_OnLostFocus" PasswordChar="*"
</PwdBox>
</AdornerDecorator>
</StackPanel>
I have 3 files where almost the same code is reused. I think there is a way to get rid of this by using a common custom control. However, I dont see much examples as to how it can be done. Any leads would be great.
Add a new UserControl to your project and move the common XAML to this one.
You could then create an instance of this UserControl (replace "UserControl1" with the actual name of your UserControl) in any other view:
<!--insert the shared markup here: -->
<local:UserControl1 />
I have an Infragistics WPF XamDoughnutChart which displays data binded from an ObservableCollection called Data and shows Data.Value and Data.Label on its chart labels.
<Grid>
<ig:XamDoughnutChart x:Name="MyDonut"
CenterData="{Binding TotalItemCount}">
<ig:XamDoughnutChart.Series>
<ig:RingSeries ItemsSource="{Binding Data}"
ValueMemberPath="Value"
LabelMemberPath="Label">
</ig:RingSeries>
</ig:XamDoughnutChart.Series>
</ig:XamDoughnutChart>
</Grid>
I am trying to change the LabelTemplate as mentioned here: https://www.infragistics.com/help/wpf/16.2/infragisticswpf.controls.charts.xamdatachart~infragistics.controls.charts.hierarchicalringseries_members
But nothing I try works. Here is my new XAML with all my attempts:
<Window.Resources>
<DataTemplate x:Key="MyLabelTemplate">
<Label Foreground="Blue" Content="test"/> <-- **This shows 'test' in blue
<Label Foreground="Blue" Content="{Binding}"/> <-- Does nothing
<Label Foreground="Blue" Content="{Binding Path=Label}"/> <-- Does nothing
<Label Foreground="Blue" Content="{Binding Path=Value}"/> <-- Does nothing
</DataTemplate>
</Window.Resources>
<Grid>
<ig:XamDoughnutChart x:Name="MyDonut"
CenterData="{Binding TotalCount}">
<ig:XamDoughnutChart.Series>
<ig:RingSeries ItemsSource="{Binding Data}"
ValueMemberPath="Value"
LabelMemberPath="Label"
LabelTemplate="{StaticResource MyLabelTemplate}"> <-- **Add a LabelTemplate**
</ig:RingSeries>
</ig:XamDoughnutChart.Series>
</ig:XamDoughnutChart>
</Grid>
How can I actually change this labels template?
SOLVED
<ig:RingSeries.LabelTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Item.Label}" Foreground="White"/>
</StackPanel>
</DataTemplate>
</ig:RingSeries.LabelTemplate>
I have used calendar control and its display mode is year when my user control is loads then calender width s too large and doesn't appear when width is set .but when is select any month then width is set as it should
i m not getting what is the issue behind it
can anyone help me quickly???
Here is my code and what ever selected month will appear in textbox's text property and on click event of button my calendar control is set to visible
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="HorizontalHorizontalAlignment="Left "Margin="4">
<Label Content="Month: " HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="15" FontWeight="DemiBold" Margin="4"/>
<TextBox Height="23" HorizontalAlignment="Stretch" Name="SelectedMonthTextBox" VerticalAlignment="Top" Width="130" Margin="4" LostFocus="SelectedMonthTextBox_LostFocus" SelectionBrush="#FF767879"/>
<Button Content=".." Height="20" Width="20" Margin="4" Name="button" Click="button_Click" />
</StackPanel>
<Calendar Grid.Row="1" Grid.Column="0" Margin="50,-8" Panel.ZIndex="100" Name="calendar1" DisplayModeChanged="calendar1_DisplayModeChanged" DisplayDateChanged="calendar1_DisplayDateChanged" HorizontalAlignment="Left" DisplayMode="Year" Style="{StaticResource CalendarStyle}" Focusable="False" HorizontalContentAlignment="Left" VerticalAlignment="Top" />
i took a look your code and from information you provided so far, there is no any change a you describe. I believe that you should check following:
What happens in calendar1_DisplayModeChanged
How defined your style: StaticResource CalendarStyle
If it possible please post them here. I will try to help as soon as possible :)
I have been trying to find a solution to this one but could not find a relevant answer online.
I have a bunch of text boxes that I need to populate with data, for example in my case address. I have a combo box that is bound to an enum and has a list of values to select from
Home, Office, MainOffice, Laboratory. etc. When I make a selection on combobox, I need to populate its address in the text boxes below. I can get Home address from object X, Office Address from Object Y, MainOffice from Z. How do I do this conditional databinding using combobox selection. Please advise.
These are the options that I could select
public enum MailToOptions
{
Home,
Office,
CorporateOffice,
Laboratory,
}
<!-- Row 1 -->
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Content="Mail To:" />
<ComboBox Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="5" Name="MailToComboBox"
ItemsSource="{Binding Source={StaticResource odp}}"
SelectionChanged="HandleMailToSelectionChangedEvent" >
</ComboBox>
<!-- Agency ID -->
<!-- Name -->
<Label Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="5" Content="Name" />
<TextBox Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="5">
<TextBox.Text>
<Binding Path="Order.Agency.PartyFullName" Mode="TwoWay" />
</TextBox.Text>
</TextBox>
<!-- Row 2 -->
<!-- Address Line 1 -->
<Label Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="5" Content="Address 1" />
<TextBox Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="5">
<TextBox.Text>
<Binding Path="Order.Agency.AddressLine1" Mode="TwoWay" />
</TextBox.Text>
</TextBox>
The best way would be to make the items in your ComboBox objects, and bind your text fields to the ComboBox.SelectedItem
For example,
<ComboBox x:Name="AddressList" ItemsSource="{Binding Addresses}" DisplayMemberPath="Name" />
<TextBox Text="{Binding SelectedItem.Street, ElementName=AddressList}" ... />
<TextBox Text="{Binding SelectedItem.City, ElementName=AddressList}" ... />
<TextBox Text="{Binding SelectedItem.State, ElementName=AddressList}" ... />
<TextBox Text="{Binding SelectedItem.ZipCode, ElementName=AddressList}" ... />
A cleaner way would be to set the DataContext of whatever panel holds the TextBoxes
<ComboBox x:Name="AddressList" ItemsSource="{Binding Addresses}" DisplayMemberPath="Name" />
<Grid DataContext="{Binding SelectedItem, ElementName=AddressList}">
<TextBox Text="{Binding Street}" ... />
<TextBox Text="{Binding City}" ... />
<TextBox Text="{Binding State}" ... />
<TextBox Text="{Binding ZipCode}" ... />
</Grid>
You can either bind the ComboBox to something like an ObservableCollection<Address>, or set the ItemsSource manually in the code behind.
I'd recommending binding, however to set it manually in the code behind it would look something like this:
var addresses = new List<Addresses>();
addresses.Add(new Address { Name = "Home", Street = "1234 Some Road", ... });
addresses.Add(new Address { Name = "Office", Street = "1234 Main Street", ... });
...
AddressList.ItemsSource = addresses;
This is how i am binding the Autocomplete Textbox:-
<sdk:AutoCompleteBox Grid.Column="1" Grid.Row="2" Height="28" HorizontalAlignment="Left" Margin="5,5,0,0" Name="autoCompleteBox" ItemsSource="{Binding List,Mode=TwoWay}" ValueMemberPath="Details" FilterMode="Contains" VerticalAlignment="Top" Width="400" SelectedItem="{Binding Path= SelectedFromList,Mode=TwoWay
<sdk:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Details}" VerticalAlignment="Center" Margin="10 0 0 0" />
</StackPanel>
</DataTemplate>
</sdk:AutoCompleteBox.ItemTemplate>
</sdk:AutoCompleteBox>
Problem is i am not able to Clear the previously searched data from the Autocompletetext box, and every time i search it show all the records that i searched previously.
Can anybody suggest how to clear previous records??
i don't know how to do this in ViewModel but in code behind in the event "Populating"
clear the selectedItem and Itemsource and bind it again and it will work,
var items = this.autoCompleteBoxSingle.ItemsSource;
this.autoCompleteBoxSingle.ItemsSource = null;
this.autoCompleteBoxSingle.SelectedItem = null;
this.autoCompleteBoxSingle.ItemsSource = items;