[WPF] AutoCompleteBox: set parameters from code behind

Hi,
I'm using AutoCompleteBox from Codeplex.com
I would set some parameters from code behind... 
In XAML, I defined namespace:
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
After using AutoCompleteBox:
<toolkit:AutoCompleteBox
x:Name="myAutoComplete"
ItemsSource="{Binding Source={StaticResource DomainDataViewModel}, Path=SampleProperties, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding Name}"
ValueMemberPath="Name"
ItemTemplate="{StaticResource PropertyBoxItemTemplate}"
MouseLeave="PropertyAutoCompleteBox_MouseLeave"
>
</toolkit:AutoCompleteBox>
If I would set any parameter from code behind, in my.xaml.cs, I not found myAutoComplete, why?
Thanks.

>>I inserted the AutoCompleteBox as DataGridTemplateColumn.CellEditingTemplate.
Then you cannot access it directly from the code-behind as I told you.
>>I would apply a FilterCustom and a ItemFilter.
You could handle the Loaded event for the AutoCompleteBox and set any of its properties in there:
<toolkit:AutoCompleteBox
x:Name="myAutoComplete"
Loaded="myAutoComplete_Loaded"
ItemsSource="{Binding Source={StaticResource DomainDataViewModel}, Path=SampleProperties, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding Name}"
ValueMemberPath="Name"
ItemTemplate="{StaticResource PropertyBoxItemTemplate}"
MouseLeave="PropertyAutoCompleteBox_MouseLeave"
>
</toolkit:AutoCompleteBox>
private void myAutoComplete_Loaded(object sender, RoutedEventArgs e)
AutoCompleteBox myAutoComplete = sender as AutoCompleteBox;
//set properties or do whatever here...
myAutoComplete.ValueMemberPath = "Name";
dynamic dataObject = myAutoComplete.DataContext;
//access any properies of the data object in the DataGrid...
How to do filtering is a completely other question that should be asked in a new thread though. It has nothing to do with your original question.
Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

Similar Messages

  • Updating a Label content from code behind using dispatcher

    hi,
    I am trying to update a label's content from code behind.
    This part of the code is running in background worker. I wrote the following code to update a label's content:
    volumecontrol.Dispatcher.BeginInvoke(new Action(() =>
    volumecontrol.Content = volumeupdate;
     i tried using both BeginInvoke and Invoke but the application exits with the error:
    System.InvalidOperationException' occurred in WindowsBase.dll
    Using Invoke works when updating the UI from another thread but it not working in this case:
    Pls help.
    Thanks,
    Shaleen
    TheHexLord

    When you do that new action stuff you're capturing variables.
    If that means you grab a control's value across from outside the {} then you're trying to capture the variable on the background thread.  If that's some sort of control you're messing with then that will cause a problem as they have thread affinity.
    Because you don't want to be blocking the UI thread at all you should use BeginInvoke rather than Invoke.
    To explain this clearly - and provide a way you could use to explore what's going on and learn  - we need a separate thread which can be done using Task.Factory.StartNew.
    This bit of code allows you to put code onto a background thread:
    Task.Factory.StartNew(() =>
    // On a separate thread to the UI here
    Create a new solution, add a textBlock and Button:
    <StackPanel>
    <TextBlock Name="tb"/>
    <Button Name="btn" Click="btn_Click">Change the text</Button>
    </StackPanel>
    Then in the button click you can play around with what's going on.
    Just to be clear.
    That textblock is a control and it is created on the UI thread.
    To get from that task thread back to the UI thread you should use Dispatcher.BeginInvoke.  With no control name.
    Let's start with a broken piece of code:
    private void btn_Click(object sender, RoutedEventArgs e)
    Task.Factory.StartNew(() =>
    string thingummy = tb.Text + "Banana";
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = thingummy; }));
    When you click the button it'll error because when you access tb.Text there you do so on a background thread and tb has thread affinity.
    This, however, will work OK.
    Task.Factory.StartNew(() =>
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = tb.Text + "Banana"; }));
    That's OK because the Action runs on the UI thread where tb was created and all is good.
    Anonymous methods and actions capture variables ( you can google that for more info ).
    If you wanted to use a variable which was created on the background thread you can set it here:
    Task.Factory.StartNew(() =>
    string thingummy = "banana";
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = thingummy; }));
    or here
    string thingummy = "banana";
    Task.Factory.StartNew(() =>
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = thingummy; }));
    They both work.
    They are not accessing properties of a UI control because you're just setting the variable to a string.
    All of which means you could have a variable in your code which is set to volume or whatever that is from your control  ON THE UI THREAD and then modify that variable on the background thread.  Variables do not have thread affinity.  A
    double, string or whatever isn't a control.
    And this approach might well be more convenient.
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • Detect current device channel from code behind

    From
    MSDN article about device channels:
    Also, device channels can set a JavaScript variable called effectiveDeviceChannel that contains the current channel alias. This variable can be used to show which channel is currently being used.
    Is there similar variable, that could be used in code behind (in C#), to determine which channel is currently used?

    You can use DeviceChannelPanel in your web part...
    For e.g. the following in a visual web part will render only to a channel that is targetted for tablets.
    <Publishing:DeviceChannelPanel runat="server" ID="pnlTab" IncludedChannels="Tab">
        You can see this tab devices.
    </Publishing:DeviceChannelPanel>
    From code behind, you can create a device channel panel dynamically and add contents to it.
    e.g.
                LiteralControl l = new LiteralControl();
                l.Text += "Sample content for tablets";
                DeviceChannelPanel dp = new DeviceChannelPanel();
                dp.Controls.Add(l);
                dp.IncludedChannels = "Tab";
                MyPanel.Controls.Add(dp);

  • Setting JSLink for XSLTListViewWebPart from code behind

    I am adding an XSLTListViewWebPart from within a user contol code behind.  It adds fine, but I am not able to get it to resolve the JSLink file.  The js file works, as I've attached it to a list view web part in the web part properties and it works.
    How do I set the JSLink property from the code?  I have set it on the view object and on the XsltListViewWebPart, but neither has any effect.  This has to be deployable from a wsp, so setting the value from the UI is not an option. 
    XsltListViewWebPart FooterMenuListView = new XsltListViewWebPart();
      FooterMenuListView.ListId = linkList.ID;
      FooterMenuListView.ViewGuid = linkView.ID.ToString("B");
      FooterMenuListView.JSLink = "/_Layouts/15/FooterMenu.js";                                
      FooterMenuListView.BorderStyle = System.Web.UI.WebControls.BorderStyle.None;
      FooterMenuListView.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
      phFooterMenuList.Controls.Add(FooterMenuListView);
    Any advice would be appreciated.

    Hi,
    Please try to use the code line below:
    FooterMenuListView.JSLink = "/_layouts/15/FooterMenu.js";
    Or you can upload the js file into a document library(JSLib) and use like this:
    FooterMenuListView.JSLink = "~site/JSLib/FooterMenu.js";
    JSLink also supports the following tokens, you can try it.
    •~site
    •~sitecollection
    •~layouts
    •~siteLayouts
    •~siteCollectionLayouts
    More information:
    http://spdevlab.com/2013/07/07/5-facts-about-jslink-in-sharepoint-2013-you-might-not-know/
    http://networkedblogs.com/GmSvo
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Set parameters from event

    I need set render parameters from event. From backing file cant find how set render paramters.

    Hello,
    I assume you are using JSR168 portlets and trying to set the render parameters when you receive an event? If so, you can't do that from the backing file; you will need to handle the event in your portlet instead of a backing file. For example, the following code would go in your portlet's java source:
    import javax.portlet.ActionResponse;
    import javax.portlet.ActionRequest;
    import com.bea.netuix.events.Event;
    public class JavaPortlet extends GenericPortlet
    // This method will receive the event. It can have any name but must
    // have this signature
    public void handleEvent(ActionRequest request, ActionResponse response,
    Event event)
    // Event handling code goes here
    // To set a render parameter, make calls like this:
    response.setRenderParameter("paramName", "paramValue");
    Then, in your .portlet file instead of a tag for "invokeBackingFileMethod" use the tag "invokeJavaPortletMethod" and specify the name of the method to call, just like the "invokeBackingFileMethod" did.
    Kevin

  • Raiseevent from code behind

    I need to use the PCC to update a secondary portlet at a specific time during the postback of a click event. Can I use the PCC to raise an event from the code behind file?

    I'm afraid you cannot do this - the PCC exists solely on the client so must be called from the client, not the server. What you can do is include some javascript to handle this instead. One simple solution would be to add the script block
    <script defer language="JavaScript">document.PCC.raiseEvent(...)</script>
    This however will only work in IE. If you want cross browser support then you will have to register for your own portlets rerender event, then upon a rerender you must check some condition which you set in the codebehind (i.e. the text in a hidden element) and raise the PCC event accordingly.

  • Newbie: Trying to get data  from Code Behind file to HTML file.

    Greetings,
    I am trying to use the opener link adaptive tag to open a specific page. I have the Object ID, and classID as variables in my class in my class file, but I do not know how to get that data into the opener link which is on the html page.
    Should I be using session variables? If so how, I am a newbie.
    Does anyone know how?
    Thanks.

    Kinda depends on your flavor/need/preference. I've done it...
    * Using session variables and just writing to the page in script blocks. Not preferred in .NET-land, but definitely more of the fast/traditional ASP style. Use sparingly and with caution. Be really careful about VS.NET totally destroying your tags. It seems to love doing that (as an aside - HUGE thank-yous to the BEA engineers who altered the tags to consistenly use lower case. Really. I can't thank you enough. :) )
    * Using label controls and then just populating the label with the formatted adaptive tag (this can work well)
    * One of our guys did a really simple/elegant server control that takes arguments for the objectid, classid, etc. Nice for creating things repeatedly server-side and gets you by the HTML, quotes, etc. all over the place. Nice as it also consolidates the tag in a single place you can alter once.
    For session variables, you'd just do something like...
    <%
    '//in your code-behind
    Session("myClassID") = 18
    Session("myObjectID") = 12345
    %>
    <!-- in your aspx file -->
    <pt:standard.openerlink xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' pt:objectid='<%=Session("myObjectID")%>' pt:classid='<%=Session("myClassID")%>' pt:mode='2' target='myWindow' onclick=window.top.open('','myWindow','height=800,width=700,status=no,toolbar=no,menubar=no, location=no');>Adaptive Tags Made This Easy - Click to Open My Awesome Document</pt:standard.openerlink>
    That help?
    Personal style, I would try to avoid using session, etc. directly on your ASPX file. I'd go with writing out the HTML through labels, data lists, etc. in your code-behind.
    Thanks,
    Eric

  • [Solved] systemd-sysctl.service failed to set parameters from 99-sy...

    $ cat /etc/sysctl.d/99-sysctl.conf
    # Protection from the SYN flood attack.
    net.ipv4.tcp_syncookies = 1
    # Disable packet forwarding.
    net.ipv4.ip_forward = 0
    # Tweak those values to alter disk syncing and swap behavior.
    vm.vfs_cache_pressure = 1000
    vm.swappiness = 0
    # USB Speed
    vm.dirty_ratio = 5
    vm.dirty_background_ratio = 3
    # KDE
    fs.inotify.max_user_watches = 524288
    $ cat /proc/sys/vm/dirty_ratio
    10
    $ cat /proc/sys/vm/dirty_background_ratio
    5
    but
    $ cat /proc/sys/vm/swappiness
    0
    $ cat /proc/sys/vm/vfs_cache_pressure
    1000
    Only restarting of systemd-systct.service helps.
    $ sudo systemctl restart systemd-sysctl.service
    $ cat /proc/sys/vm/dirty_ratio
    5
    $ cat /proc/sys/vm/dirty_background_ratio
    3
    what am i doing wrong?
    Solved with - % sudo chmod -x /usr/lib/pm-utils/power.d/laptop-mode
    Last edited by Perfect Gentleman (2013-09-20 00:34:44)

    Perfect Gentleman wrote:Solved with - % sudo chmod -x /usr/lib/pm-utils/power.d/laptop-mode
    A more permanent solution is to mask that file
    mkdir -p /etc/pm/power.d
    touch /etc/pm/power.d/laptop-mode
    which will not get written on update or reinstall. (Not than an update to this package seems at all likely but just in case.)

  • How To Force Open Document In Edit Mode From Code-Behind (Chrome and Firefox)?

    Hello,
    Currently I am developing an IHttpHandler which at the should redirect the user to an Edit mode of a document located in a Document Library.
    The Problem is that in Firefox and Chrome it downloads the document in the temp folder. In IE it works as expected.
    The following code is used for the redirection:
    SPUtility.Redirect(urlOfTheNewDocument, SPRedirectFlags.Trusted, context);

    Hi,
    Please try to use IE Tab.
    Chrome IE Tab:
    https://chrome.google.com/webstore/detail/ie-tab/hehijbfgiekmjfkfjpbkbammjbdenadd?hl=en 
    Firefox IE Tab:
    https://addons.mozilla.org/en-us/firefox/addon/ie-tab/
    Here is a similar thread for your reference:
    http://stackoverflow.com/questions/14455212/how-to-open-sharepoint-files-in-chrome-firefox
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • How to Get Resource value which are referred in code behind file using IResourceProvider

    Hi Everyone,
    Currently I'm working on moving the Resource file from "App_GlobalResources" to Database by using IResourceProvider. I created a CustomResourceProvider project using ResourceProviderFactory and able to get the resource values from DB which
    are used in aspx page.
    But i'm not able to get the values which are referring from code behind file.
    Ex: Label1.Text = Resources.Common.Car; // This is still coming from resx file.
    Can any one please let me know how to get the value from DB instead of resx file which are referred in cs file.
    Appreciate your help. 
    The below code uses the ResourceProviderFactory which calls this method and gets it from DB. Please let me know if you need any more info.
    public class DBResourceProviderFactory : ResourceProviderFactory
            public override IResourceProvider CreateGlobalResourceProvider(string classKey)
                return new DBResourceProvider(classKey);
            public override IResourceProvider CreateLocalResourceProvider(string virtualPath)
                 // we should always get a path from the runtime
                string classKey = virtualPath;
                if (!string.IsNullOrEmpty(virtualPath))
                    virtualPath = virtualPath.Remove(0, 1);
                    classKey = virtualPath.Remove(0, virtualPath.IndexOf('/') + 1);
                return new DBResourceProvider(classKey);
    Regards, Ravi Neelam.

    Hi Ravi Neelam.
    >>Currently I'm working on moving the Resource file from "App_GlobalResources" to Database by using IResourceProvider.
    Based on this message, your issue related to web application, questions related to Asp.Net should be posted in
    Asp.Net forum.
    Please reopen a new thread in that forum. You will get more efficient response.
    Regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to execute SQL Query in Code behind Using infopath 2010?

    Hi,
    I've repeatable on infopath form, and want bind it throuth code behind from SQL table. My question is that how to execute SQL Query in code behind from infopath as well as how would get Query result to bind repeatable control?
    Thanks In Advance
    Shoeb Ahmad

    Hello,
    You first need to add new SQL DB connection then you need execute connection from code behind.
    See below link to create new connection
    http://office.microsoft.com/en-in/infopath-help/add-a-data-connection-to-a-microsoft-sql-server-database-HP010092823.aspx:
    http://www.bizsupportonline.net/infopath2010/connect-infopath-2010-sql-server-2008-table.htm
    Then use below code to execute this connection:
    AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections["Data connection name"]);
    string origCommand = Select * from tablename;
    conn.Command = origCommand;
    conn.Execute();
    Finally bind your table:
    http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm
    http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Error Message in Code Behind Visual Web Part

    I want to show validation message in code behing when i click submit button,below is my code
    <asp:TextBox ID="txtBoxName" runat="server" Width="50%"></asp:TextBox>
    <asp:RequiredFieldValidator ID="rfvCompanyName" ControlToValidate="txtBoxName"
    ValidationGroup="RegistrationGrp" SetFocusOnError="True" runat="server" Text="*" ErrorMessage="Please Enter Name"></asp:RequiredFieldValidator>
    protected void btnSubmit_Click(object sender, EventArgs e)
    i want to show this error message "Please enter name"
    from code behind,how do i do that??

    I am inserting item from the input textbox in the sharepoint list in submit button like below,so i did what u suggested in that click event
    protected void btnSubmit_Click(object sender, EventArgs e)
                   if (!Page.IsValid)
                        rfvCompanyName.ErrorMessage = "test test";
                        return;
                        using (SPWeb web = site.OpenWeb())
                            SPList list = web.Lists["Company Details"];
                            SPListItem item = list.Items.Add();
                            item["Title"] = txtBoxName.Text;
                            item.Update();
    but it's not showing this message,please suggest what i am missing

  • I'm new to the LabView. How do I pass data from VI configured using Serial (CMTS using CLI commands to set Parameters ) to VI configured using GPIB(vecto​r signal analyzer ) to measure such as RF frequency or power on the instrument​? Thanks

    I'm new to the LabView. How do I pass data from VI configured using Serial (CMTS using CLI commands to set Parameters ) to VI configured using GPIB(vector signal analyzer ) to measure such as RF frequency or power on the instrument?
    I just want to set something on the front panel that will execute the Serial parameters first and then pass these settings to vector signal analyzer
    Thanks
    Phong

    You transfer data with wires.
    Frankly, I'm a little confused by your question. I can't think of any reason why you would want to pass serial parameters (i.e. baud rate, parity) to a GPIB instrument. Please explain with further detail and attach the code.

  • Assign Tabitem Style from xaml in Code behind

    Hi
    I have a style defined for TabItem in XAML.
    I am generating the TabItem Dynamically and i want to add the Style create from XAML to the tabitem that is created dynamicaly.
    Here is my XAML code
    <TabControl Name="tc" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="White">
    <TabControl.Resources>
    <Style TargetType="TabItem" x:Key="hi">
    <Setter Property="VerticalAlignment" Value="Bottom" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type TabItem}">
    <Grid>
    <Border Name="Border" Background="LightBlue" BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="2,12,12,2" > <ContentPresenter x:Name="ContentSite"
    VerticalAlignment="Center"
    HorizontalAlignment="Center"
    ContentSource="Header"
    Margin="12,2,12,2"/>
    </Border>
    </Grid>
    <ControlTemplate.Triggers>
    <Trigger Property="IsSelected" Value="True">
    <Setter TargetName="Border" Property="Background" Value="LightSkyBlue" />
    </Trigger>
    <Trigger Property="IsSelected" Value="False">
    <Setter TargetName="Border" Property="Background" Value="GhostWhite" />
    </Trigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </TabControl.Resources>
    </TabControl
    in code behind i am trying to assign the style
    private void example_Click_1(object sender, RoutedEventArgs e)
    try
    ExampleGrid ex = new ExampleGrid();
    Close_Tab theTabItem = new Close_Tab();
    theTabItem.Title = "my Grid";
    tc.Items.Add(theTabItem);
    theTabItem.Style = (Style)FindResource("hi");
    theTabItem.Content = ex;
    theTabItem.Focus();
    catch (Exception ee)
    MessageBox.Show(ee.Message);
    I am getting an exception saying resource hi is not found
    Note: hi is the name of the style.
    Please suggest me the solution for this.
    Thanks All

    I believe if you remove x:key attribute from the tab style
    <Style TargetType="TabItem"> ... </Style>
    then it will be applied to all tabs.
    If this not works then take out your style definition from <TabControl.Resources> and put it the resource of parent control which contains TabControl
    e.g
    <UserControl ...>
    <UserControl.Resources>
    <Style TargetType="TabItem"> ... </Style> // don't add x:key attribute
    </UserControl.Resources>
    <TabControl> .. </TabControl>
    </UserControl>

  • How to call a Web Api from from a Visual webpart code behind?

    Hi,
    I am trying to create a visual web part in sharepoint 2013 with data received from another Web API.
    I followed the below steps.
    1. Created a Visual Web part.
    2. In the code behind(.cs) file I wrote the following code.
     async private void GetResult()
                using (var client = new HttpClient())
                    client.BaseAddress = new Uri("http://localhost:8080/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = await client.GetAsync("api/Tfs/OpenEnquiriesCount");
                    var content = response.Content;
    3. When I run the application, I get security exception in the line await
    client.GetAsync()
    What is the way to achieve this? How to call a web api from share point visual web part?
    Thank you in advance.

    Hi,
    Thanks for your sharing.
    Cheers,
    Jason
    Jason Guo
    TechNet Community Support

Maybe you are looking for

  • Creative Cloud member wants to publish multi-folios for a client...

    Hello everyone, I did send this question as a"private message" first and did receive some answers that I would like to share here. Big thank you to both Himanshu and Bob!!!  If someone feels like adding more info regarding the subject please do. "I’m

  • How do I save as?

    How do I "save as?" I recently upgraded to Pages from Appleworks and it's very slick but how do I "save as" an existing document? In other words, I have one resume with contact info for every job I've ever had, and I used to delete info from it until

  • Making entries in table TCLO

    Hi, I want to add some objects in TCLO table in order to make document links for O4V1,04G1 T-code in DMS (CV01n/2n/3n/4n). I want to link Vehicles with DMS is it possible??? Thanx & Best Rgds, Akhil

  • Equium L10 needs a driver for DVD-RAM drive

    It's rather embarrassing, but in recent days I've come to find that somehow, the driver for my DVD RAM (Mat****a UJ830s) is somehow corrupt or missing. I've searched high and low over the net to find the right driver to reinstall, but I can't find a

  • Mapbuilder import TTF - Wingdings

    Hi. Mapbuilder (v.11.1.1.0.0) can't see true type fonts like: Wingdings or Webdings in an "import true type font". It's empty after choosing one of this fonts and importing it into mapbuilder. Why ?? Edited by: Monteusz on 2009-11-24 09:20